Data Structures & AlgorithmsHardGATE CS · Product placement
Keys 47, 74, 63, 43, 45, 59, 85 are inserted in this order into an empty table of size 13 using quadratic probing: probe i goes to (k mod 13 + i²) mod 13 for i = 0, 1, 2, …. In which slot is 85 placed?
- A. 10
- B. 7
- C. 4
- D. 3
Correct answer: D. 3
85 hashes to 7. Offsets 0, 1, 4, 9, … are added to the home slot; the first free slot is 3 (probe i = 3). Linear probing would have placed it in slot 10.
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 does this loop-counting code print? (Python) python n, c = 300, 0 i = 2 while i <= n: c += 1 i = i i print(c)
- Integer square root by binary search (largest m with m·m ≤ n). What is printed (root, iterations)? python n, lo, hi, it = 1000, 0, 1000, 0…
- A mountain is a contiguous subarray of length ≥ 3 that strictly increases to a single peak and then strictly decreases. What is the length…
- How many inversions (pairs i < j with a[i] > a[j]) does [38, 33, 1, 17, 31, 28, 18, 35] have? (This is also the number of swaps bubble…
- What is the worst-case number of comparisons made by binary search (three-way comparison per probe) on a sorted array of 1,000 elements…
- Keys 110, 52, 100, 101, 53, 74, 96 are inserted in this order into an empty table of size 13 using quadratic probing: probe i goes to (k…