Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern
Keys 50, 700, 76, 85, 92, 73, 101 are inserted into a hash table of size 7 with h(k) = k mod 7 and linear probing. What is the final table (slots 0–6)?
Keys 50, 700, 76, 85, 92, 73, 101 are inserted into a hash table of size 7 with h(k) = k mod 7 and linear probing. What is the final table (slots 0–6)?
m = 7; t = [None] * m
for k in (50, 700, 76, 85, 92, 73, 101):
i = k % m
while t[i] is not None: i = (i + 1) % m
t[i] = k
print(" ".join("-" if x is None else str(x) for x in t))- A. 700 50 85 73 101 92 76
- B. 700 50 92 85 73 101 76
- C. 700 85 50 92 73 101 76
- D. 700 50 85 92 73 101 76
Correct answer: D. 700 50 85 92 73 101 76
Home slots: 50→1, 700→0, 76→6, 85→1 (taken) →2, 92→1 →2 →3, 73→3 →4, 101→3 →4 →5. Primary clustering makes later keys walk past the growing cluster at slots 0–5.
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 22, 33, 44, 55 go into a table of size 11 with quadratic probing h(k) + i² (mod 11). In which slots do they land, in order? python m…
- What is printed? (stack-based reversal of words) python s = "data structures are fun" st = [] for w in s.split(): st.append(w) out = []…
- Convert the infix expression to postfix (^ is right-associative, higher than and /, which are higher than + and −). What is printed?…
- Evaluate the postfix expression with single-digit operands. What is printed? python st = [] for t in "62/3-42+": if t.isdigit()…
- What is printed? (deque operations) python from collections import deque d = deque([1, 2, 3]) d.appendleft(0); d.append(4) d.rotate(2)…
- What is printed? (singly linked list, delete every node whose value equals x) python class N: def init(s, v, n=None): s.v, s.n = v, n h =…