16,068 views
0 0 votes
Which of the following is the least suitable hash function H(x) where X is some non negative integer ?

1. h(k) =k%n

2.h(k) =k*k %n

3.h(k)=(gcd(k+1,2k+2) +k ) %n

Linear probing is used for collision resolution .

1 Answer

1 1 vote
Considering k from 0 to 9 and n=10

Case(1): h(k)=k%10

0%10=0,1%10=1,2%10=2 similarly 9%10=9

Collision rate=0

Case(2):h(x)=k*k%10

(0*0)%10=0

(1*1)%10=1

(2*2)%10=4

(3*3)%10=9

(4*4)%10=6

(5*5)%10=5

(6*6)%10=6

(7*7)%10=9

(8*8)%10=4

(9*9)%10=1

Collision rate=4/10

Case(3):h(k)=(gcd(k+1),(2k+2)+k)%10

0--->(gcd(1,2)+0)%10=1

1-->(gcd(2,4)+1)%10=3

2-->(gcd(3,6)+2)%10=5

3-->(gcd(4,8)+3)%10=7

4-->(gcd(5,10)+4)%10=9

5-->(gcd(6,12)+5)%10=1

6-->(gcd(7,14)+6)%10=3

7-->(gcd(8,16)+7)%10=5

8-->(gcd(9,18)+8)%10=7

9-->(gcd(10,20)+9)%10=9

Collision rate=5/10

Since collision rate is highest for case(3), it is least likely to be selected as a hash function
Position:
Show:

Related questions

60 60 votes
4 answers 4 answers
25.1k
25.1k views
Arjun asked Feb 12, 2020
25,094 views
Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
6 6 votes
1 1 answer
298
298 views
GO Classes asked Jul 28
298 views
For the keys:$47, 61, 36, 52, 56, 33, 92$consider the hash function:$h(k) = ((10k + 4) \bmod c) \bmod 7$Find the smallest positive integer $c$ such that no collisions occ...
5 5 votes
1 1 answer
210
210 views
GO Classes asked Jul 28
210 views
Which of the following statements are true?$\text{S1}$. The worst-case complexity of checking whether an object is present in a hash set is $O(1)$.$\text{S2}$. The worst-...
5 5 votes
2 2 answers
258
258 views
GO Classes asked Jul 18
258 views
A key consists of three uppercase English letters. The hash value $h$ of a key is calculated as:$h = (\text{sum of alphabetical positions of the three letters}) \bmod 27$...