哈希表的问题(英文)100分指教

binghe7 2003-11-17 08:53:16
麻烦写下详细步骤每步做什么的谢谢
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'.
...全文
41 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
liang79930 2003-11-20
  • 打赏
  • 举报
回复
加我QQ27375934详谈!
binghe7 2003-11-19
  • 打赏
  • 举报
回复
哎,水平不够啊~
楼上的拜托啊
rexp 2003-11-19
  • 打赏
  • 举报
回复
linux下有hcreate,hsearch,hdestroy这几个函数,并且里面都带有源代码,拿过来看一下就知道人家的hash表怎么实现了,学习学习一下他们的算法,主要在于映射函数。
binghe7 2003-11-18
  • 打赏
  • 举报
回复
无人能解?不至于吧,100分呀,HELP
chinajiji 2003-11-18
  • 打赏
  • 举报
回复
仅从这道题就可以看出出这道题的老师很负责的.
chinajiji 2003-11-18
  • 打赏
  • 举报
回复
多好的一个练习啊,居然不自己做!
好比一道美餐,却要让别人品尝后你却来吃人家嚼过的渣渣.
gladiatorcn 2003-11-18
  • 打赏
  • 举报
回复
解题关键是选择优秀的hash function,看来核心问题就是求解最优的质数p的问题了,程序本身并不难写。
将输入的值域映射到有限的空间,确定p是没有多项式算法的。你可以尝试几个合理的值,如果都超出范围,可以把hash table的最后一项变成一个附加的链表,专门承载超出范围的值。
不难哦!只是懒得写程序了。
binghe7 2003-11-18
  • 打赏
  • 举报
回复
晕,还没有高手来呀~
郁闷
binghe7 2003-11-17
  • 打赏
  • 举报
回复
晕,我是需要结果和做的过程啊
不过谢谢楼上的翻译出来,高手继续
winco 2003-11-17
  • 打赏
  • 举报
回复
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 length 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.
写一个程序用哈希表来存储字符串。哈希表的长度应该为700。给你一个含有3部分的文件,长度分别是180,425和850。文件在http://www.staff.ncl.ac.uk/albert.koelmans/data.txt。这三步分用一个'-'在每部分的开头分开。你要把哈希方法分别应用导每个部分,并计算出结果。

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).
建议使用下面哈希函数:H=int(k)mod700, 这里int(k)=P*k+c总计了所有字符串中ASCII码c的个数,k=0为其初始值。P是一个恰当的质数(你可以自己选择)
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:
针对3部分的每个哈希表,你的程序应该用下列标准来衡量来衡量你的哈希表的效率
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.
a. 哈希表中空指针的百分数
b. 链表的平均长度
c. 哈希表中最长链表的长度
These results should be presented by your program in easily digestible 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.
a. 源程序
b. 哈希统计表
c. 搜索结果
d. 你的分析结果(不超过2页),包括你所选择的哈西函数和这样选的原因

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.
你的程序会根据一下标准来打分:你的程序设计是否合理,你用的函数是否正确,你处理3个部分是否用了最少的重复代码,你是否选择了一个合理的哈希函数以及你给出结果的方法。
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'.

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧