Data Structures & AlgorithmsVery hardGATE CS
A hash table of size 11 uses double hashing: the probe sequence for key k is (k mod 11 + i · (7 − (k mod 7))) mod 11 for i = 0, 1, 2, .... The keys 41, 52, 63, 30, 74, 19, 85 are inserted in this order. In which slot does key 19 end up?
- A. 5
- B. 0
- C. 2
- D. 10
Correct answer: D. 10
Insert in order, probing until an empty slot: the final slots are [8, 1, 4, 2, 0, 10, 3], so 19 lands in slot 10. With plain linear probing it would land in slot 2, because the step for 19 is 7 − (19 mod 7) = 2, not 1.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- A hash table of size 7 uses h(k) = k mod 7 with linear probing. A delete leaves a tombstone, an insert goes into the first empty or…
- A circular queue is stored in an array of size 6 (indices 0-5). Initially empty, front = 0, and an enqueue stores at index (front + count)…
- A singly linked list holds 1, 2, ..., 11 in order. Starting from the head, every alternate group of k = 3 consecutive nodes is reversed in…
- For the array [7, 2, 4, 9, 3, 5, 1, 8, 6, 2, 10, 4, 3, 9] and window size k = 4, compute (maximum - minimum) for every window of k…
- The span of a day is the number of consecutive days ending that day (including it) whose price is at most that day's price. For prices…
- Bars of unit width have heights [3, 0, 2, 0, 4, 0, 1, 3, 0, 2, 5, 1, 0, 3]. After rain, how many units of water are trapped between the…