Data Structures & AlgorithmsVery hardTCS Digital · Infosys SP
Keys 112, 95, 54, 144, 21, 31, 32 are inserted in this order into an empty table of size 11 by double hashing: h1(k) = k mod 11, h2(k) = 7 − (k mod 7), probe i at (h1(k) + i·h2(k)) mod 11. In which slot is 32 placed?
- A. 5
- B. 10
- C. 3
- D. 2
Correct answer: A. 5
h1(32) = 10 and h2(32) = 3; stepping by 3 from the home slot, the first free slot is 5 after 3 probe(s).
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
- Longest substring that can be turned into one repeated letter with at most k replacements (sliding window, window − maxfreq ≤ k). What is…
- A checker counts how many strings are balanced over (), [] and {}. Version A uses a stack; version B only keeps one counter of open minus…
- A 2-D prefix-sum table answers rectangle queries in O(1). For the 4 × 4 matrix (rows separated by ';', 0-based) 1 3 7 6; 6 8 8 6; 1 9 7 8…
- How many contiguous subarrays of [3, −2, 5, 0, −2, 1, 4, 5, 0] have sum exactly 5? (Prefix sums with a hash map of prefix-sum frequencies.)
- A circular queue in an array of size 5 keeps one slot empty to tell full from empty (front = rear means empty; (rear + 1) mod 5 = front…
- Insertion sort (ascending; shift larger elements right, one key comparison per inner-loop test, the loop stops at the first element ≤ the…