CS14 - At-Home Programming Assignment 5

Project due Sunday, March 14 at 8:00 pm


Updated - March 7, 3PM - Added a bit more clarification to the average length calculation description.
Updated - March 5, 5PM - Added "SUCCESSFUL" to print stats description and gave you an updated sample.out. Also fixed a typo in hash.h

In this project, you will write a program to hash 5 letter words. You will decide on your own hash function. Use seperate chaining. You must use the Standard Template Library list class for your chains. The program will consist of two parts: passing the functionality tests and the success of your hash function. Your grade will be based on the functionality tests. We will then compare the success of your hash function will the other students in the class. Extra credit will be given to a few of the top hashing functions. For us to test the functionality, you need to write at least the following functions in your Hash class. You must use the function prototypes provided. If you change these function prototypes at all, your code will not interface with the test file and your project will not be graded.

The Hash Function

You will need to write your own hash function for the project. You will need to write a unique and original hash function so that you can be eligible for extra credit (you are competing the creativity of the other students). Your hash function must be contained within hash_function.cc. Hash_function.cc already contains a very simple and very poor hash function. You will need to delete the contents of the hash function and replace it with your own hash function. You MUST define and use the hash function in hash_function.cc and link this file to your project in your makefile. This is extremely important because to test the functionality of your program, we will be replacing your hash function with our own. Actually, we will simply download a fresh copy of hash_function.cc and compile and run your program. If we are unable to do this, you will lose points on your project.

At the top of this file, you will need to describe your hash function, why it is good, and how you happened upon it.

Defining the hash table size

The size of your hash table should be specified as a defined value. If you look at hash_function.cc you will see that there is a value HASH_TABLE_SIZE that is not defined in this file. For this assignment, you will be learning something new. Using a command line parameter to g++, you can define the value of constants used within your program during compilation. This is accomplished using the -D flag (usage = "-D HASH_TABLE_SIZE=10"). This example sets the hash table size to 10 for your program. This table size is extremely small so I suggest you test your program with table sizes into the thousands. So for this project, the flags to g++ in your makefile will be "-Wall -W -Werror -pedantic -g -D HASH_TABLE_SIZE=X" where X will be replaced with whatever size you want your table to be. Using this method will make it very simple for us to test your programs for different situations.

Provided Files

The hash competition

Extra credit will be available for the top few hash functions (don't ask how much extra credit or how many students will get it.) To be eligible for the hash competition, your hash statistics must match mine EXACTLY during the functionality testing phase (see the stats at the bottom of sample.out and make sure that yours are EXACTLY the same. The reason for this is fairness. We have to make sure that you tally your stats correctly before we can compare your stat with the other students. We will test table sizes of 2004, 10007, and 15659 with dict5.txt and random.txt. Use these files and these table sizes to tune your hash function.

Special note - you must have a unique hashing function to get extra credit. If the top hashing functions are too similar, those students will share a small amount of extra credit. This is to ensure that you do not talk with the other students about your hashing function.

Programming

Be sure to use good programming where possible (use of classes, functions, good parameter passing techniques, operator overloading, templates, error checking). Part of your grade will be based on your actual coding.

What to turn in

You should have turned in what you have thus far on our program at least 6 hours before the due date (by 2pm). Then continue to work on your program and turn in more current versions as you get them working. Ideally, you should have your project done well before the due date.

You must turn in all .cc and .h files and your makefile. In addition, you must follow any guidelines and include any information that is stated on the main page about at-home programming assignments.

A reminder about collaboration on home programming assignments

Please remember, at-home programming assignments are not lab assignments and you may not team-code with your lab partner or any other individual. Limited collaboration may be acceptable, but programs must represent YOUR OWN original work. Sharing code or team-coding are strictly not allowed. Copying code from ANY source (any book, current or past students, past solutions, web, etc) is strictly not allowed even with citation. Collaboration may consist of discussing the general approach to solving the problem, but should not involve communicating in code or even pseudo-code. Students may help others find bugs. Your code MUST be unique -- the odds of randomly producing similar code is very low. Computing, like surgery or driving a car or playing golf, can only be learned by doing it yourself!