Data Structures & AlgorithmsHardTCS Digital · Infosys SP
Keys 81, 25, 26, 79, 49, 55, 59, 93 are inserted in this order into an empty table of size 11 with h(k) = k mod 11 and linear probing. Counting the first slot examined as one probe, how many probes in total do the 8 insertions make?
- A. 15
- B. 16
- C. 8
- D. 17
Correct answer: B. 16
Probes per key: 1, 1, 2, 1, 2, 1, 4, 4, total 16. Counting only collisions (probes beyond the first) would give 8.
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
- Only the lower triangle (including the diagonal) of a 10 × 10 matrix is stored COLUMN by column in a 1-D array B starting at B[0] (indices…
- A min-stack keeps a second stack of running minimums. What is printed? python st, mn, out = [], [], [] for op in [8, "pop", 8, 8, "pop"…
- Reverse a singly linked list in groups of k (a final group shorter than k is left as it is). What is printed? python def revk(h, k): cnt…
- Print a matrix in spiral order (right, down, left, up, repeat). What is printed? python m = [[50, 81, 32, 23], [30, 61, 32, 23], [60, 51…
- 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…
- 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…