Added comments to the source file.

Much improved comments. Successfully tested the updated file with the
test cases supplied at the discussion forum for Assignment 2:
https://class.coursera.org/rprog-003/forum/thread?thread_id=650