Data Structures & AlgorithmsVery hardGATE CSE · Hashing
A hash table of size 7 with h(k) = k mod 7 and linear probing holds keys 3, 10, 17, 24 at indices 3, 4, 5, 6. Key 10 is then deleted by marking its slot as a 'deleted' tombstone (not empty). How many slots are examined to find key 24 afterwards?
- A. 2
- B. 3
- C. 5
- D. 4
Correct answer: D. 4
A search continues past tombstones and stops only at an empty slot or the key: indices 3, 4 (tombstone), 5 and 6 are examined.
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
- How many pairs of positions (i < j) in [5, 3, 7, 9, 1, 2, 6, 10, 14, 4] have a[i] + a[j] divisible by 4?
- A greedy stack algorithm removes exactly 3 digits from the number string "1432219" to get the smallest possible number (keeping the order…
- A cache with 3 slots serves the page requests 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5. How many misses occur under LRU replacement and under…
- What is the time complexity of reading the element arr[i] from an array of n elements, given i?
- Which data structure works on the Last In, First Out (LIFO) principle?
- What is the worst-case time complexity of binary search on a sorted array of n elements?