Homework Assignment 8 Solutions

Program: You are to write the UniqueWords.C program. Invoked with a file name on the command line, the program opens the file, reads the contents, parses the individual words in the file, and keeps a list of all the words in the file, each word in the list once, with a count of how many times the word appears in the file.
Solution

First accomplish this program adding new words to the head of the list. The problem with this method is that frequent words end up at the back of the list, making searching slow. You are next ot write MoveToFront.C which implements the Move To Front algorithm to speed up the program.
Solution

Note to 597 students only: here is the Perl solution to this problem: