Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
A table of size 11 uses double hashing with h1(k) = k mod 11 and h2(k) = 1 + (k mod 9), probe position (h1 + i*h2) mod 11. Keys 5, 16, 27 are inserted in this order, then 38. At which slot does 38 finish?
- A. 7
- B. 8
- C. 0
- D. 3
Correct answer: B. 8
5, 16, 27 land in 5, 2 (16: 5 full, step 8) and 6 (27: 5, 5+1=6). For 38, h1 = 5 and h2 = 1 + 2 = 3: probe 5 (full), then 8 (empty). Dropping the '1 +' gives step 2 and slot 7; taking h2 from h1 (step 6) gives 0, and 3 is h2 itself.
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
- 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?
- What is the length of the longest substring of abcabcbbxyzw that contains no repeated character?