Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft
Keys 13, 14, 24, 27, 70, 76, 91, 15 are inserted in this order into an empty hash table of size 13 with h(k) = k mod 13 and linear probing. In which slot does 15 end up?
- A. 2
- B. 10
- C. 4
- D. 5
Correct answer: C. 4
15 hashes to 2, which is occupied; linear probing tries the following slots one by one and finds the first free one at 4 after 3 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
- Keys 55, 63, 47, 69, 16, 97, 39, 99, 77, 43 are inserted in this order into a chained hash table with 7 buckets, h(k) = k mod 7, and each…
- Floyd's cycle detection on a list whose last node links back into the list. What does this print (meeting value, cycle-start value, cycle…
- What does this loop-counting code print? (Python) python n, c = 70000, 0 i = 2 while i <= n: c += 1 i = i i print(c)
- In the binary array [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0] you may flip at most 2 zeros to ones. What is the length of the longest run…
- Evaluate an infix expression of single digits with two stacks (operands and operators, usual precedence, left-associative). What is…
- Swap every two adjacent nodes of a linked list by relinking (not by swapping values). What is printed? python def swappairs(h): d = p =…