中国互联网电视是什么:【高手请进】跪求数据结构难题2

来源:百度文库 编辑:高校问答 时间:2024/04/27 14:46:09
A hash table with hash function
H1(k)=k mod 13 is shown below.

0 1 2 3 4 5 6 7 8 9 10 11 12
26 38 17 33 48 35 25
Collision is resolved using the hash function H2(k)=(k mod 11)+1

(59)How many key comparisons occur in serching for key 35 in the given hash table?
A)0 B)1 C)2 D)3
(60)If a new key 67 is inserted into the given hash table,what will be its address?
A)3 B)4 C)5 D)6
请具体说明,如果能够解释清可以+50

补充1:算了把答案说出来可能会得到比较好的解释,59:D;60:B
因为在【高手请进】跪求数据结构难题中也是同样让我吃惊所以我有理由怀疑有另外的算法来求解,而不是我想象中的如1楼所说的求法,还有59题不是发生冲突的次数而是在查找35时的比较次数

补充2:可能的次序是26->0,25->12nd,38->12nd->1st(不是2是第1个位置),17->4th,33->7th,48->9th,35-10th??

请大家帮忙结实啊,有点莫名其妙啊,马上就要考试了

至于这到题怀疑题目本身有错

首先计算
35 mod 13=9 ,发生冲突
所以用 H2即 9 mod 11 +1=10
找到了35,所以冲突发生一次
即选B

首先67 mod 13=2,因为2已经存了38,所以用H2
即2 mod 11 +1 =3
所以存的位置为3
即选A

对于已知条件有点奇怪,如果说散列函数是H1(k)=k mod 13 。冲突函数是H2(k)=(k mod 11)+1。48 35和25 38是怎么放进去的?好象不能用散列函数存入吧?

哦,H2(k)中k是取H1(k)的值,不好意思没看清楚