The Task

This is an extension of the id3 program you wrote in assignment 1. It is a chance to get it working if you did not before. This has two parts. First, improve the id3 algorithm you wrote. Second, add the -t option to the program. I have done the coding for you so you don't have to know much to do the parsing.

If you call the program without the -t it will perform as it did in assignment 1. With one exception. When about to recurse on the ID3Build with no data instead return an Ans using maxAns for the current data rather than the subsetted data which is empty for that value of the feature. At the end of printing all the output for the tree as before have it also print the actual tree data structure with print(tree).

If the -t option is supplied have it read in the tree data structure from the file whose name is given with the -t option. Code for reading in the file and putting the data structure will be supplied. Now proceed to read from standard input as before using readProblem(). For each read data vector print the data including the expected answer and then the answer the tree would give.

See example outputs to see what is expected for output. Here is a template for how to organize your code and in particular get the input and output right. The test data has example outputs plus those outputs print the internal tree for your inspection.


Homework will be submitted as an uncompressed tar file. In the tar file will contain a file named exactly: All the files in the tar file will be exploded onto the test machine but only will be run. See homework submission page linked from the services section of the class web page. You can submit as many times as you like. The LAST file you submit BEFORE the deadline will be the one graded. For all successful submissions you will receive email at your mail address giving you some automated feedback on the unpacking and compiling and running of your code on test data and possibly some other things that can be autotested.

Have fun.