当前位置:首页计算机类软件水平考试中级软件设计师->对于关键字序列(26,25,72,38,8,18,59),采

对于关键字序列(26,25,72,38,8,18,59),采用散列函数H(Key)=Keymod13构造散列表(哈希表)。若采用线性探测的开放定址法解决冲突(顺序地探查可用存储单元),则关键字59所在散列表中的地址为(  )。

  • A.6
  • B.7
  • C.8
  • D.9
查看答案 纠错
答案: D
本题解析:

根据题目给出的散列函数我们可以分别计算出关键字(26,25,72,38,8,18,59)对应的散列地址分别为(0,12,7,12,8,5,7)。

开放定址处理冲突的基本思路是为发生冲突的关键字在散列表中寻找另一个尚未占用的位置,其解决冲突能力的关键取决于探测序列,在本题中,题目告诉我们采用顺序探查法,即增量为1的线性探测法,在该线性探测法中,设Hi(1≤i<m)为第i次在散列表中探测的位置,其中增量序列为{1,2,3,4,5,…,m-1}则有:

Hi=(H(Key)+i)%m

其中H(Key)为散列函数,m为散列表长度,i为增量序列。而本题中m=13。因此本题的散列表构造过程如下:

(1)关键字26,25,72由散列函数H(key)得到没有冲突的散列地址而直接存入散列表中。

(2)计算关键38的散列地址为12,发生冲突(与关键字25冲突),其第一次线性探测地址为(12+1)%13=0,但仍然发生冲突(与关键字26冲突),因此需要进行第二次线性探测,其地址为(12+2)%13=1,这时没有发生冲突,即将38存入地址为1的空间。

(3)接着将关键字8,18计算其散列地址,由于没有冲突,即分别存入散列地址为8和5的空间中。

(4)计算关键59的散列地址为7,发生冲突(与关键字72冲突),其第一次线性探测地址(7+1)%13=8,但仍然发生冲突(与关键字8冲突),因此需要进行第二次线性探测,其地址为(7+2)%13=9,这时没有发生冲突,即将59存入地址为9的存储空间。

因此本题的答案选D。

更新时间:2021-12-12 06:29

你可能感兴趣的试题

单选题

(  )is the process of transforming information so it is unintelligible to anyone but the intended recipient.

  • A.Encryption
  • B.Decryption
  • C.Security
  • D.Protection
查看答案
单选题

As each application module is completed,it undergoes(  )to ensure that it operates correctly and reliably.

  • A.unit testing
  • B.integration testing
  • C.system testing
  • D.acceptance testing
查看答案
单选题

(  )algorithm specifies the way to arrange data in a particular order.

  • A.Search
  • B.Random
  • C.Sorting
  • D.Merge
查看答案
单选题

After analyzing the source code,(  )generates machine instructions that will carry out the meaning of the program at a later time.

  • A.an interpreter
  • B.a linker
  • C.a compiler
  • D.a converter
查看答案
单选题

(  )can help organizations to better understand the information contained within the data and will also help identify the data that is most important to the business and future business decisions.

  • A.Data processing system
  • B.Big Data analytics
  • C.Cloud computing
  • D.Database management
查看答案
单选题

浏览器开启无痕浏览模式后,(  )依然会被保存下来。

  • A.浏览历史
  • B.搜索历史
  • C.已下载文件
  • D.临时文件
查看答案
单选题

下列协议中,不属于TCP/IP协议簇的是(  )。

  • A.CSMA/CD
  • B.IP
  • C.TCP
  • D.UDP
查看答案
单选题

下列传输介质中,带宽最宽、抗干扰能力最强的是(  )。

  • A.双绞线
  • B.红外线
  • C.同轴电缆
  • D.光纤
查看答案
单选题

数控编程常需要用参数来描述需要加工的零件的图形。在平面坐标系内,确定一个点需要2个独立的参数,确定一个正方形需要(  )个独立的参数。

  • A.3
  • B.4
  • C.5
  • D.6
查看答案
单选题

某书的页码为1,2,3,...,共用数字900个(一个多位数页码包含多个数字),据此可以推断,该书最大的页码为(  )。

  • A.237
  • B.336
  • C.711
  • D.900
查看答案