Data Structures & AlgorithmsHardWipro · Accenture pattern
Keys 22, 33 and 44 are inserted in that order into an empty table of size 11 with h(k) = k mod 11 and quadratic probing hᵢ(k) = (h(k) + i²) mod 11. At which index is 44 placed?
- A. 2
- B. 4
- C. 1
- D. 3
Correct answer: B. 4
All three keys hash to 0. 22 → 0; 33 tries 0, then 0 + 1 = 1; 44 tries 0, 1 (both full), then 0 + 4 = 4. Linear probing would have put 44 at 2.
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
- Two sorted lists of 5 and 7 elements are merged by the standard merge procedure. What is the maximum number of comparisons it can make?
- A fixed-size sliding window of length 3 moves over [2, 1, 5, 1, 3, 2, 9, 1]. What is the largest window sum?
- How many element shifts does insertion sort perform to sort [4, 3, 2, 10, 12, 1, 5, 6] in ascending order?
- Quick sort with the Lomuto partition (pivot = last element) is run on an already sorted array of 10 distinct elements. How many…
- Binary search (one three-way comparison per probe) is done on a sorted array of 1000 elements. What is the maximum number of probes needed?
- This code tries to reverse the singly linked list 1 → 2 → 3 → 4, but its last line has been changed from cur = nxt. What does the list…