Data Structures & AlgorithmsVery hardProduct placement · Amazon/Microsoft
Keys 121, 29, 37, 91, 13, 33, 39 are inserted in this order into an empty table of size 13 by double hashing: h1(k) = k mod 13, h2(k) = 7 − (k mod 7), probe i at (h1(k) + i·h2(k)) mod 13. In which slot is 39 placed?
- A. 3
- B. 6
- C. 0
- D. 2
Correct answer: B. 6
h1(39) = 0 and h2(39) = 3; stepping by 3 from the home slot, the first free slot is 6 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
- Delete every alternate node (2nd, 4th, …) of a linked list, then reverse what remains. What is printed? python def delalt(h): p = h while…
- Asteroids move along a line: positive values move right, negative move left; on collision the smaller (by absolute value) explodes, equal…
- Lines of heights [9, 5, 3, 2, 4, 9, 1, 2, 9] stand at x = 0, 1, …, 8. Two pointers find the pair of lines that, with the x-axis, holds the…
- How many different pop sequences are possible when 6 distinct items are pushed onto a stack in a fixed order, with pops allowed at any time?
- Count zero-sum contiguous subarrays with a prefix-sum frequency map. What is printed? python from collections import defaultdict a = [1…
- Daily prices are [26, 31, 28, 30, 24, 30, 18, 37, 13]. What is the maximum profit with at most ONE buy and one later sell, and with…