Data Structures & AlgorithmsVery hardProduct placement · Amazon/Microsoft
A chained hash table stores n = 2,000 keys in m = 500 buckets with simple uniform hashing. What is the expected number of key comparisons in a SUCCESSFUL search?
- A. About 4 (α)
- B. About 2 (α/2)
- C. About 3 (1 + α/2 with α = 4)
- D. About 5 (1 + α)
Correct answer: C. About 3 (1 + α/2 with α = 4)
With load factor α = n/m = 4, a successful search examines on average 1 + α/2 − α/(2n) ≈ 3 elements; an unsuccessful search would examine about α = 4 (plus computing the hash).
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
- Bars of width 1 have heights [5, 5, 7, 8, 6, 5, 2, 8]. What is the area of the largest rectangle that fits under the histogram (computed…
- Product of all elements except self, using prefix and suffix products (no division). What is printed? python a = [2, 3, 3, 2, -1] n =…
- What does this loop-counting code print? (Python) python n, c = 16, 0 i = 1 while i < n: j = i while j < n: c += 1 j = 2 i += 1 print(c)
- For the sorted array [1, 3, 4, 6, 6, 9, 9, 11, 13, 14, 14, 15] (0-based), what are lowerbound(14) (first index with value ≥ 14) and…
- Records are sorted with a composite key. What is printed? python recs = [('kabir', 80), ('dev', 70), ('meera', 70), ('ravi', 70), ('zoya'…
- Stock prices over 8 days are [21, 87, 49, 49, 28, 34, 81, 65]. The span of day i is the number of consecutive days ending at day i…