Data Structures & AlgorithmsHardProduct placement · Amazon/Microsoft
Keys 80, 25, 99, 55, 30, 13, 57, 42 are inserted in this order into an empty table of size 13 with h(k) = k mod 13 and linear probing. Counting the first slot examined as one probe, how many probes in total do the 8 insertions make?
- A. 11
- B. 3
- C. 12
- D. 8
Correct answer: A. 11
Probes per key: 1, 1, 1, 1, 1, 1, 1, 4, total 11. Counting only collisions (probes beyond the first) would give 3.
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
- A queue is implemented with two stacks (push to IN; pop from OUT, refilling OUT from IN only when OUT is empty). Which statement is correct?
- ^ is exponentiation (highest precedence, right-associative); and / come next; + and − are lowest; others are left-associative. What is the…
- Selection sort (ascending; in pass i find the minimum of the unsorted part and swap it into position i only if it is not already there) is…
- Only the lower triangle (including the diagonal) of a 12 × 12 matrix is stored row by row in a 1-D array B starting at B[0] (indices…
- Count palindromic substrings by expanding around all 2n − 1 centres, and also count DISTINCT palindromic substrings. What is printed?…
- You need to sort 10⁷ integers, each in the range 0 to 999. Which approach is asymptotically fastest?