next up previous
Next: Checks Up: Second assignment Previous: Searching the dictionary

Storing misspelled words

If a word does not appear in the dictionary, you will need to store the word and its line number in some suitable data structure, ready for printing after reading the whole of the text file. It is up to you to choose a suitable data structure for storing the misspelled words. A binary search tree is a simple answer, since this will also do the sorting for you (if you define a suitable ordering on pairs, assuming you are storing words and their line numbers). But there are other possibilities.

Remember that it is part of the specification that misspelled words must be printed in alphabetical order and that each individual misspelled word is printed exactly as it occurred in the text file. Furthermore, if the same misspelled word occurs on two different lines, it is best to print the misspelled word once followed by a list of the line numbers on which it occurs. If the same misspelled word occurs more than once on a single line, you may decide for yourself whether to list that line number once, or as many times as the misspelled word occurs on that line.

Note: if you find it difficult to meet all these requirements, then just do as much as you can (ignore the line numbers, for example, or even the upper and lower case issue).


next up previous
Next: Checks Up: Second assignment Previous: Searching the dictionary
Peter Williams 2005-06-07