GATE Computer ScienceModerateGATE CS (PYQ pattern)
Keys 10, 20, 30, …, 100 are inserted in this order into an empty hash table of size 10 with h(k) = k mod 10 and quadratic probing (h(k) + i²) mod 10 for i = 0, 1, …, 9. A key whose 10 probes all hit occupied slots is rejected. How many of the 10 keys are stored?
- A. 10
- B. 6
- C. 5
- D. 7
Correct answer: B. 6
All keys hash to 0, and i² mod 10 for i = 0…9 takes only the values 0, 1, 4, 9, 6, 5 — six distinct slots. So 10, 20, 30, 40, 50, 60 fill slots 0, 1, 4, 9, 6, 5, and from 70 on every key is rejected even though slots 2, 3, 7, 8 are free.
More Algorithms questions
- A hash table of size 13 uses double hashing: the probe sequence is (k mod 13 + i·(1 + (k mod 11))) mod 13. Keys 19, 27, 36, 10, 25, 40, 53…
- For the array [8, 3, 10, 1, 7, 5, 12, 2, 9, 4, 6], let X be the number of exchanges bubble sort performs and Y the minimum number of swaps…
- A queue is implemented by two stacks (enqueue pushes onto IN; dequeue pops from OUT, first moving all elements of IN to OUT if OUT is…
- Keys 15, 9, 12, 4, 18, 7, 3, 10, 21, 6 are inserted one by one into an empty binary min-heap (array representation, standard sift-up)…
- Floyd's Build-Heap performs at most height(v) exchanges while sifting down node v, so its exchanges are bounded by H = Σ height(v) over…
- A 3-ary min-heap stores 1000 keys in an array A[0..999], with the children of A[i] at 3i + 1, 3i + 2 and 3i + 3. How many of the keys are…