GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A table of size 13 uses double hashing, probe i of key k is (k mod 13 + i * (1 + k mod 11)) mod 13. Keys 18, 41, 22, 44, 59, 32, 31, 73 are inserted in order. How many collisions (failed probes) happen in total, and in which slot does key 73 end up?
- A. 5 collisions, slot 8
- B. 4 collisions, slot 9
- C. 4 collisions, slot 8
- D. 2 collisions, slot 8
Correct answer: C. 4 collisions, slot 8
Insert each key with its own step size. The probe counts per key are [0, 0, 0, 1, 0, 1, 2, 0], so 4 failed probes in all; the final table is [None, None, 41, None, 32, 18, 44, 59, 73, 22, None, None, 31].
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A BST on 31 keys is perfectly balanced (all 5 levels full). Searching for each of the 31 keys with equal probability, what is the average…
- Keys 1 to 5 are inserted into an empty BST in a uniformly random order of the 120 possible orders. In how many of the orders does key 3…
- Iterative postorder uses two stacks: push the root on S1; repeat: pop x from S1, push x on S2, push x's left child then its right child on…
- struct N { int v; int next; }; struct N a[6] = {{10,3},{20,5},{30,-1},{40,1},{50,2},{60,4}}; int i = 0, s = 0, k = 1; while (i != -1) { s…
- How many structurally distinct binary search trees on keys 1..7 have key 4 at the root and height exactly 3 (a single node has height 0)?
- char s = "abracadabra"; int c[26] = {0}, i; for (i = 0; s[i]; i++) c[s[i] - 'a']++; int best = 0; for (i = 1; i < 26; i++) if (c[i] (i +…