CMSC206 Data Structures
Fall 2015
Assignment 6
Due on Tuesday, Dec. 1, 2015
This assignment contains THREE parts. Please read carefully before starting on the assignment.
Part #1: Write a simplified Binary Search Tree class by implementing the TreeInterface interface as follows:
Part #2 Make a program that uses the BST from part #1 to:
Use the add() method to add the following strings to the BST:
After adding the above, do a preorder, postorder, and inorder traversal (printing out each node as you visit). Also print out the number of entries in the tree, and its height. You will need use the three methods: preOrder(), postOrder(), and inOrder() that you implemented in the binary search tree class from Part #1.
Clear the tree, and print out the number of items and its height. Then add the above towns in ascending order. Print out the resulting tree's size, and height, and also the results of all three tree traversals.
Save your output as Part2.txt.
Part #3: Redo Assignment#4 to use 1 entry per town (with a list of all zip codes) and entries stored in a Binary Search Tree (as implemented in Part #1) using the string TOWN+STATE as the ordering relation.
For demonstrating the correctness of your program, include a printout that shows the output from following queries:
Additionally, after reading in the input file, your program should print the height of the resulting tree.
The objective here is to compare the performance of your program from Assignment#4. As before, once you have completed the program, extend it to count the number of comparisons needed to answer a query. Then, for the input data above, compute the average number of comparions needed
to answer a query, the average number of comparisons needed to answer a successful
query, the average number of comparisons needed to answer an
unsuccessful query. Next, compare these results to those obtained in
Assignment#4.
Save the output of the program as Part3.txt.
What to Hand-in (on Moodle):
A zip file containing: