Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft
Keys 28, 19, 53, 91, 92, 20, 74, 89 are inserted in this order into an empty hash table of size 10 with h(k) = k mod 10 and linear probing. In which slot does 89 end up?
- A. 6
- B. 7
- C. 5
- D. 9
Correct answer: C. 5
89 hashes to 9, which is occupied; linear probing tries the following slots one by one and finds the first free one at 5 after 7 probes.
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
- Print a matrix in spiral order (right, down, left, up, repeat). What is printed? python m = [[10, 41, 52, 63], [20, 51, 42, 53], [40, 41…
- Binary search with mid = (lo + hi) // 2 (lo = 0, hi = n − 1, loop while lo ≤ hi) looks for 86 in [11, 13, 17, 24, 25, 32, 36, 58, 65, 86…
- Rabin–Karp with a good rolling hash is used to find a pattern of length m in a text of length n. Which statement is correct?
- Reverse the order of words, collapsing multiple spaces. What is printed? python s = " the is new code " w = s.split() print("|" + "…
- Rabin–Karp with base 10 and a deliberately small modulus counts true matches and spurious hits (hash equal, text different). What is…
- 11 people stand in a circle numbered 1 to 11. Counting starts at person 1, and every 4th person is removed (counting continues from the…