哈希表的问题(英文)100分指教
麻烦写下详细步骤每步做什么的谢谢
Project 1 Topic: hashing, searching.
Write a program that uses hashing to store a series of strings. The hash table should have a length of 700. You are given a data file which contains three sections of lenght 180, 425, and 850 respectively. The file is here(http://www.staff.ncl.ac.uk/albert.koelmans/data.txt). The sections are separated by a single line containing a '-' in the first position. You should apply your hashing scheme to each of the sections separately, and compare the results.
The following hashing function is suggested: H = int(k) mod 700, where int(k) = P*k+c summed for all ASCII codes c in the string, where k = 0 is the start value. P is a suitably chosen prime number (choose it yourself).
The method of dealing with collisions should be the dynamic linked list version.
Your program must analyze the efficiency of your hashing scheme by determining the following statistics about your hash table for each of the three sections:
a. The percentage of NULL pointers in the hash table.
b. The average length of linked lists.
c. The longest linked list in the hash table.
These results should be presented by your program in easily digestable form. After seeing the results, you might want to try to improve upon your hashing scheme if the number of collisions is excessive.
Finally, the data file contains a small fourth section with search words. You should search for each word in your final hash table, and report whether each word is present or not.
Your submission should contain the following:
- a listing of the program;
- a presentation of the hash table statistics;
- a presentation of the search results;
- your analysis of the results (max two pages), including your choice of hash function and why you chose it that way.
The program will be marked according to the following criteria: whether the layout of the program is good, whether you have used functions properly, whether you've dealt with the three sections of data with minimum duplication of code, whether you've chosen a sensible hash function, and how you've presented the results.
Note that you can easily read data from a file by issuing the following command:
prog < data.txt
This makes it appear to the program 'prog' that the data was typed at the keyboard, while it actually comes from file 'data.txt'.