Data Structures & AlgorithmsVery hardGATE CS · TCS NQT
Keys 10, 22, 31, 4, 15, 28, 17, 88, 59 are inserted in this order into an open-addressing table of size 11 with h(k) = k mod 11 and linear probing (probe index +1 mod 11). At which slot (0 to 10) does the key 88 finish?
- A. 1
- B. 2
- C. 0
- D. 4
Correct answer: A. 1
Walk the probe sequence from 88 mod 11 = 0, skipping slots already taken by earlier keys. Forgetting that earlier keys occupy the slots changes the answer by one slot.
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 table of size 11 uses double hashing with h1(k) = k mod 11 and h2(k) = 1 + (k mod 9), probe position (h1 + ih2) mod 11. Keys 5, 16, 27…
- What is the value of the prefix-function (KMP failure function) at the last position of the string aabaaab?
- What is the sum of the Z-function values Z[i] for i = 1 to n-1 of the string aaabaaab (Z[i] is the length of the longest common prefix of…
- How many palindromic substrings (counted by position, so repeated letters at different positions count separately) does the string…
- What is the minimum number of characters that must be inserted anywhere in the string abcbd to make it a palindrome?
- How many distinct non-empty substrings does the string ababa have?