Programming Assignment #3

 

CS163: Data Structures

 

 

 

 

Problem Statement:

Hash tables are very useful in situations where an individual wants to quickly find their data by the “value” or “search key”.  You could think of them as similar to an array, except the client program uses a “key” instead of an “index” to get to the data. The key is then mapped through the hash function which turns it into an index!

 

You have decided to write a table abstract data type, using a hash table/function with chaining (for collision resolution), to support searching through your contacts list.

 

Now with the way phone work, having an up-to-date contacts list is very useful. But, I find that after awhile my contacts list has grown to be unmanageable. One application I use is one that logs the phone calls from my contacts to my calendar. So, if I want to quickly find out who I talked to on July 4th, I just look up that date and there are the contacts – organized by the time.

 

You have decided to implement a contact list mapped to the calendar using hashing. Have the user enter in a date and it will hash on that key value and provide all contacts called on that day.

 

FOR EXTRA CREDIT you can also implement a second hash table that hashes on the person’s name.

 

Remember, with hashing, an exact match is required. So, if the user mistypes the date or person’s name, it will never be found.

 

Abstract Data Type:

Write a C++ program that implements and uses a table abstract data type to store, retrieve, and remove contact information (name, phone number, email address, fax number if appropriate, and a log of the dates where calls were made). You can change what information you use…if you would prefer other information.

 

What does retrieve need to do? It needs to supply back to the calling routine information about all of the contacts that were called on a given date. Retrieve, since it is an ADT operation, should not correspond with the user (i.e., it should not prompt, echo, input, or output data).

 

Implement the abstract data type using a separate header file (.h) and implementation file (.cpp). Only include header files when absolutely necessary. Never include .cpp files!

 

 

Syntax Requirements:

1) Use iostream.h for all I/O; do not use stdio.h

2) Implement the table ADT as a class; provide a constructor and a destructor.

3) Make sure to protect the data members so that the main() program does not have direct access.

4) Your main() should allow the user to interactively insert, delete, or retrieve items from the table. ***THE MAIN PROGRAM SHOULD NOT BE AWARE THAT HASHING IS BEING DONE! ***

 

 

 

REMINDERS: Every program must have a comment at the beginning with your first and last name, the class (CS163) and section, the name of the file, and the assignment number. Don’t forget to write the design document! This is essential!