CSCI 311 - Fall 2007 - Program 1
Dynamic Hashing
Dr. Melody Stapleton, Instructor
Shaun McCluskey, Teaching Assistant
Due Date: All Program Components: Thursday, October 4, uploaded by midnight
Your TA, Shaun, will provide the final input file(s) to run your program against by Thursday, September 14. Shaun will also provide documentation, and style guidelines in the labs.
Your are to implement the Dynamic Hashing Algorithm, as discussed in class and posted in the course notes on the web using appropriate C++ classes.
You are to structure your main program to accept and interpret file input with the following format:
You will need to write your program to first accept the power of 2 (from the input file, on the first line) that will be used for the hash function mod value. Be sure to return an error to the user if they do not enter a power of 2 and then halt execution of (exit) the program. Return the error to the output file. The next line on the input file will be the bucket size to be used for each bucket.
Listed below are the possibilities for the different categories of commands that will follow the above 2 lines:
You will, of course, need to write a hash function, and you will need to create a Dynamic_Hash class that has at least the following member functions:
Note: You will also need to implement "chaining to overflow buckets" as discussed in class and shown in the course notes.
Output: Send your output for this program to a file. For inserts, it is an error to insert a duplicate value in the Hash structure, be sure to notify the user of such an attempt. Tell the user if an operation is successful, as well. Be sure to give appropriate "error" messages back to the user of your program, via the output file. For e.g., if asked to delete a value from the Hash structure that is not found in the structure, you should reply that the value was not found and so could not be deleted. For the Search operation, as well as returning the appropriate pointer as described above, if the item being sought is found, print out a message that says you found it and what its value is. On the other hand, if the item is not found, print out a message to that effect.
Also Note: You are responsible to write a program that deals with *all cases*. That is, your program should not only *work good on some input files*, it need to work on *all possible* input files. This means it is not your TAs responsibility to give you an input file that allows your program to work. It is your responsibility to write code that cannot be broken by any input file and so will work in all cases. This will be the case for every program you write for this course.
A sample file follows that adheres to the input file format:
8
5
I 46
I 55
I 88
P
S 46
S 99
I 99
D 50
S 200
I 200
D 55
P
I 120
I 200
I 300
I 400
I 500
S 300
P
D 600
D 500