GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A hash table of size 11 uses linear probing with h(k) = k mod 11. Keys 43, 22, 33, 54, 65, 76, 87, 14, 25 are inserted in this order (no deletions). How many extra probes (beyond the first slot tried) are used in total, and in which slot does key 25 land?
- A. 23 extra probes, slot 7
- B. 26 extra probes, slot 7
- C. 26 extra probes, slot 5
- D. 30 extra probes, slot 8
Correct answer: B. 26 extra probes, slot 7
43, 54, 65, 76, 87 hash to slot 10 and 22, 33 hash to slot 0, so they pile into slots 10 and 0 to 5 in one wrapped cluster; 14 and 25 (hash 3) must then skip to slots 6 and 7. The extra probes add up to 26.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A table of size 11 uses quadratic probing h(k, i) = (k mod 11 + i^2) mod 11. Keys 23, 34, 45, 56, 67, 78, 89 (all congruent to 1 mod 11)…
- Twenty keys are hashed into a chained table with 8 slots, each key independently and uniformly. What are the expected number of colliding…
- struct node { int d; struct node n; }; struct node f(struct node p, int k) { if (p == NULL) return NULL; struct node cur = p, prev = NULL…
- Keys 5, 3, 8, 3, 9, 1, 8, 5 are inserted one by one into an initially empty sorted singly linked list; each insertion scans from the head…
- Two sorted lists, X with 5 keys and Y with 7 keys (all 12 keys distinct), are merged with the standard two-pointer merge that stops…
- A singly linked list 10 -> 11 -> ... -> 19 is rearranged by a routine that places all nodes at odd positions (1st, 3rd, ...) first…