Hash
Question 1 |
Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
46, 42, 34, 52, 23, 33 | |
34, 42, 23, 52, 33, 46 | |
46, 34, 42, 23, 52, 33 | |
42, 46, 33, 23, 34, 52 |
Discuss it
Question 2 |

10 | |
20 | |
30 | |
40 |
Discuss it
Question 3 |
A | |
B | |
C | |
D |
Discuss it
Question 4 |
8, _, _, _, _, _, 10 | |
1, 8, 10, _, _, _, 3 | |
1, _, _, _, _, _,3 | |
1, 10, 8, _, _, _, 3 |
Discuss it
- - - - - - -
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 1 is 0, so let us put the value at 0 1 - - - - - -
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 3 is 6, so let us put the value at 6 1 - - - - - 3
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 8 is 0, but 0 is already occupied, let us put the value(8) at next available space(1) 1 8 - - - - 3
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 10 is 6, but 6 is already occupied, let us put the value(10) at next available space(2) 1 8 10 - - - 3
0 1 2 3 4 5 6 Question 5 |
8, _, _, _, _, _, 10 | |
1, 8, 10, _, _, _, 3 | |
1, _, _, _, _, _,3 | |
1, 10, 8, _, _, _, 3 |
Discuss it
- - - - - - -
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 1 is 0, so let us put the value at 0 1 - - - - - -
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 3 is 6, so let us put the value at 6 1 - - - - - 3
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 8 is 0, but 0 is already occupied, let us put the value(8) at next available space(1) 1 8 - - - - 3
0 1 2 3 4 5 6The value of function (3x + 4)mod 7 for 10 is 6, but 6 is already occupied, let us put the value(10) at next available space(2) 1 8 10 - - - 3
0 1 2 3 4 5 6 Question 6 |
i only | |
ii only | |
i and ii only | |
iii or iv |
Discuss it
Hash function given is mod(10). 9679, 1989 and 4199 all these give same hash value i.e 9 1471 and 6171 give hash value 1
Question 7 |
(97 × 97 × 97)/1003 | |
(99 × 98 × 97)/1003 | |
(97 × 96 × 95)/1003 | |
(97 × 96 × 95)/(3! × 1003) |
Discuss it
Probability that the first 3 slots are unfilled after the first 3 insertions =
(probability that first item doesn't go in any of the first 3 slots)*
(probability that second item doesn't go in any of the first 3 slots)*
(probability that third item doesn't go in any of the first 3 slots)
= (97/100) * (97/100) * (97/100) Question 8 |
Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for i ranging from 0 to 2020?
h(i) = (12 ∗ i) mod 10 | |
h(i) = (11 ∗ i2) mod 10 | |
h(i) =i3 mod 10 | |
h(i) =i2 mod 10 |
Discuss it
Since mod 10 is used, the last digit matters.
If you do cube all numbers from 0 to 9, you get following
Number Cube Last Digit in Cube 0 0 0 1 1 1 2 8 8 3 27 7 4 64 4 5 125 5 6 216 6 7 343 3 8 512 2 9 729 9
Therefore all numbers from 0 to 2020 are equally divided in 10 buckets. If we make a table for square, we don't get equal distribution. In the following table. 1, 4, 6 and 9 are repeated, so these buckets would have more entries and buckets 2, 3, 7 and 8 would be empty.
Number Square Last Digit in Square 0 0 0 1 1 1 2 4 4 3 9 9 4 16 6 5 25 5 6 36 6 7 49 9 8 64 4 9 81 1
Alternative approach -
Using concept of power of cycle:
(a) (0,1,4,9,6,5,6,9,4,1,0) repeated
(b) (0,1,8,7,4,5,6,3,2,9) repeated
(c) (0,1,4,9,6,5,6,9,4,1,0) repeated
(d) (0,2,4,6,8) repeated
So, only h(i) =i3 mod 10 covers all the digits from 0 to 9.
Option (B) is correct.
Question 9 |
80 | |
0.0125 | |
8000 | |
1.25 |
Discuss it
Question 10 |
- A hash function takes a message of arbitrary length and generates a fixed length code.
- A hash function takes a message of fixed length and generates a code of variable length.
- A hash function may give the same hash value for distinct messages.
I only | |
II and III only | |
I and III only | |
II only |
Discuss it


