COMP 212
Programming Assignment 3
Due May 10, 2000

I bet you always wondered which symbol table implementation would be best in a situation where you insert items in order of key value but remove them in random order and which would be best when the opposite happens, i.e., the items are inserted randomly but removed in order. Well, here is your chance to find out. To this end your first task is to implement three versions of a symbol table:

1.
ST1 - using an ordered array with binary search and lazy remove.

2.
ST2 - using an ordinary binary search tree.

3.
ST3 - using one of a randomized binary search tree, a splay binary search tree, a 2-3-4 tree, a red-black tree or a skip list (your choice).

For each version you should supply methods for (i) initializing an empty symbol table (ii) inserting an item into the symbol table (iii) searching for an item with a given key value in the symbol table and (iv) removing an item with a given key value from the symbol table. Assume that in case of multiple copies of items, searching and removing applies to any one of the copies. (In the tests below, we will ensure that all items are distinct.)

Having implemented (and hopefully tested they are correct!) the above versions you are to compare how well they perform on the following two sets of tests, for N=2i*10000, i=0, 1, 2, 3, 4.

1.
Insert N items with key values 1, 2, 3, ..., N into the symbol table, in order of smallest to largest. Perform N randomly generated search operations on keys in the table. Remove the items in random order. (See note below on generating a random permutation.) You should time your symbol table separately on the time required for the inserts, searches and removes.
2.
Insert N items with key values 1, 2, 3, ..., N into the symbol table, in random order. Perform N randomly generated search operations on keys in the table. Remove the items in order of smallest to largest. Again, you should time your symbol table separately on the time required for the inserts, searches and removes.

You should include in your source a commented section containing a table of your results. Also comment on how the results meet with your expectations considering the properties of each of the implementations.


Some Notes:



 

2000-04-25