Data Structures & AlgorithmsHardHCLTech · Wipro pattern
Keys 26, 63, 80, 39, 14, 99, 18, 93, 44 are inserted via linear probing (h(k) = k mod 11, probe by +1 on collision) into an initially empty table of size 11 (indices 0 to 10). What is the final table, left to right (_ = empty)?
- A. 99/44, _, _, 80/14, 26, 93, 39, 18, 63, _, _
- B. 99, 44, _, 80, 26, 18, 39, 14, 63, 93, _
- C. 99, 44, _, 80, 26, 14, 39, 18, 63, 93, _
- D. _, 93, 63, 18, 39, 14, 26, 80, _, 44, 99
Correct answer: C. 99, 44, _, 80, 26, 14, 39, 18, 63, 93, _
Each key goes to h(k) = k mod 11, and on a collision the next slot (wrapping around) is tried until an empty one is found. Simulating all insertions in order gives [99, 44, _, 80, 26, 14, 39, 18, 63, 93, _]. Using quadratic probing (+1², +2², ...) instead would give a different table, [99, 44, _, 80, 26, 18, 39, 14, 63, 93, _], since the probe sequence differs after the first collision.
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 of capacity 4 starts empty and runs this sequence in order: enqueue(3), enqueue(1), enqueue(6), enqueue(9), dequeue()…
- What is the postfix (Reverse Polish) form of the infix expression "i (f + c)- a / h", built with the standard stack-based conversion (^…
- Array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] is left-rotated by d = 1 positions using the reversal algorithm (reverse first d, reverse rest…
- A recursive function is defined as f(0) = f(1) = 1 and f(n) = f(n−1) + 2·f(n−2) for n ≥ 2. Using memoization, what is f(7)?
- Kadane's algorithm runs on the array [-4, 3, 9, 3, 3, -6, 7, 4, 6] to find the maximum sum of a contiguous subarray. What sum does it…
- Binary search for first/last occurrence runs on the sorted array [2, 5, 6, 16, 19, 19, 20, 21] for target 19. What (first index, last…