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

binghe7 2003-11-17 08:52:36
麻烦写下详细步骤每步做什么的谢谢
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'.
...全文
62 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
TianGuangZao 2003-11-22
  • 打赏
  • 举报
回复
我给大概译了一下,参考:

项目 1 题目:哈希算法, 查找算法。

使用哈希算法写一个存储字符串组的程序。哈希表长度要求为 700。给你一个数据文件,由三部分组成,长度分别为 180,425 和 850。该文件位于(http://www.staff.ncl.ac.uk/albert.koelmans/data.txt)。这三部分由 '-' 开头的单线分隔。你要把你所设计的哈希方案分别应用到每一部分,并比较结果。

以下是有关哈希函数的提示: H = int(k) mod 700, 这里 int(k) = P*k+c 表示字符串中所有字符 c 的 ASCII 码之和(译者注:这句我也看不懂),k = 0 为开始值。 给 P 选择一个合适的素数(由你决定)。

遇到冲突时的处理方法:请采用动态链接表这种形式。

你的程序必须分析所采用的哈希方案的效率,通过你的哈希表对三个部分中任何一个所做的下列问题的统计结果来判断:

a. 哈希表中空指针的比例。
b. 链表的平均长度。
c. 哈希表中最长的链表。

要求你的程序用简明易懂的表单形式把这些结果表示出来。在观察完结果后,如果发现过多的冲突,回想方设法提高你的哈希方案。

最后,数据文件还包含了第四部分,为少数搜索关键词。在你最终定稿的哈希表中查找每一个词,并且报告该词是否存在。

你提交的方案应包含如下几方面:
- 一个程序列表
- 一份哈希表的统计结果简述
- 一份搜索结果的简述
- 你对结果的分析报告(最多两页),包括你选择的哈希函数以及为什么选它的理由。

程序将根据以下标准打分:程序的布局是否合理,所使用的函数是否正确,你在处理这三部分数据时是否符合最小重复代码,你所选择的哈希函数是否明智,以及你是如何来表示结果的。

注意使用下面命令你能很轻松的从一个文件中读取数据:

prog < data.txt

从 prog 看来似乎是从键盘键入数据的,实际上是来自文件 'data.txt'。
guokai1217 2003-11-22
  • 打赏
  • 举报
回复
我也解决过类似的问题.是用vb和vc实现的.不过说起来太费时间了。还是好好看一下英语和算法与数据结构把.
ywchen2000 2003-11-21
  • 打赏
  • 举报
回复
把离散学好在说呀。


================================================================
灌水-----无尽的任务。
proware 2003-11-19
  • 打赏
  • 举报
回复
写程序还是翻译

69,371

社区成员

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

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