Data Structures and Algorithms II

Program 1

Topic: Binary Search Tree Implementation of a Dictionary / Odd Words Application

The Odd Words application must catalog all of the words in a document that appear an odd number of times. For our purposes, a word is any white-space delimited string; case does not matter. Do not assume that words will be short! Your application must open a file (specified by the user) and read the words in the file. If the file is not found, the program should terminate. You must determine which words in the document appear an odd number of times. To do this, use a dictionary ADT, storing all of the words that have appeared an odd number of times. Hint: if the next word from the document is found in the Dictionary, remove it, otherwise insert it. Produce a report in a file (name again specified by the user) listing all of the "odd" words (all lower case and alphabetized), one word per line. The report should state the name of the document file, the total number of words processed, and the number of "odd" words found in the document.

The Dictionary interface is slightly different from the one in the text. In particular, a removeMin has been added to allow you to extract the information in alphabetic order. The two comparison classes have been combined into one. This is important as the lt, gt, and eq functions must give consistent results for key:element and element:element comparisons. That is, if element e1 has key k1, then the comparisons between k1:e2 and e1:e2 must be the same. Although it is possible for a Dictionary to contain duplicate data, your application should prevent this from occurring.

You may not need all of the methods, but you must implement them all. Be sure to test them.

You should design your own class to represent the "odd" word data. This will basically contain a dynamically allocated string and the necessary assignment operator and copy constructor. It would be a great idea to overload the stream insertion and extraction operators. The stream extraction operator should be prepared for arbitrarily long words. You will also need to supply the appropriate comparison class.

I have included a startup project that can be downloaded. You must use the templates as provided in this download. An unzip utility will be needed to extract the files. You may get a free one here if you do not already have one. The archive contains a single folder named your_name_1 which will contain the project files. After unzipping, rename the folder to your name with a 1 at the end (example: t_margush_1).

Be sure to document your work. Avoid using friends in your classes.

Your finished project must be zipped and submitted via email by the due date. Mail the project to margush@uakron.edu and use the subject line: DSAII Program 1 Submission. Please organize your project in the same manner as the provided framework - all project files in one folder named your_name_1. Delete or empty the Debug folder before zipping. Zip the entire project folder and contents so when I unzip it, everything is in a single folder named with your name and the project number.