Data Structures & AlgorithmsHardGATE CS
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 tombstone slot on its probe path (without checking for duplicates), and a search skips tombstones and stops at a truly empty slot. After inserting 10, 17, 24, 3, 31, then deleting 17 and 24, then inserting 45 and 38, how many slots are examined by a successful search for 38?
- A. 5
- B. 4
- C. 3
- D. 2
Correct answer: C. 3
Final table (None = empty, D = tombstone): [31, None, None, 10, 45, 38, 3]. Searching for 38 starts at slot 38 mod 7 = 3 and examines slots until it finds 38, which takes 3 probes; the tombstones left by deletions are probed past but do not stop the search.
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 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…
- For the array [3, 1, 2, 4, 1, 5, 2, 6], what is the sum of the minimum element over all contiguous subarrays?