Data Structures & AlgorithmsHardGATE CSE · Hashing
Keys 10, 21, 32, 43, 54 are inserted in this order into an empty table of size 11 using h(k) = k mod 11 and quadratic probing, the i-th probe being (h(k) + i^2) mod 11. At which index does 54 end up?
- A. 4
- B. 2
- C. 8
- D. 9
Correct answer: A. 4
All keys hash to 10. 21 goes to 0, 32 to 3 (probe 2), 43 to 8 (probe 3), and 54 tries 10, 0, 3, 8 (taken) before probe 4 gives (10 + 16) mod 11 = 4.
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
- The numbers 1, 2, 3, 4, 5, 6 are pushed onto an empty stack in this order, with pops allowed at any time between pushes. Which of the…
- How many contiguous subarrays of [3, 4, 7, 2, -3, 1, 4, 2] have a sum of exactly 7?
- What is the length of the shortest substring of "AXBYAZCBAB" that contains at least two A's, at least one B and at least one C?
- Seven people numbered 1 to 7 stand in a circle (a circular linked list). Counting starts at person 1, and every 3rd person is removed…
- What is the area of the largest rectangle in a histogram with bar heights [3, 6, 5, 7, 4, 8, 1, 0, 6] and unit width?
- What is the maximum sum of a non-empty contiguous subarray of [3, -4, 2, -3, -1, 7, -5] if you may delete at most one element from the…