Data Structures & AlgorithmsEasyInfosys · Capgemini pattern
A hash table has 7 slots and uses h(k) = k mod 7. In which slot is the key 50 placed if that slot is empty?
- A. 7
- B. 0
- C. 1
- D. 6
Correct answer: C. 1
50 = 7 × 7 + 1, so 50 mod 7 = 1. Slot indices run 0–6, so '7' is not even a valid slot; the quotient is 7, not the remainder.
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
- Operators have the usual precedence ( and / above + and −, all left-associative). What is the postfix form of A (B + C) / D − E?
- What is the value of the prefix expression + 3 4 − 9 / 8 2 ?
- Selection sort (find the minimum of the unsorted part, swap it to the front only if it is not already there) sorts [29, 10, 14, 37, 13]…
- Binary search with mid = (lo + hi) / 2 (integer division) looks for 31 in [3, 9, 14, 20, 27, 31, 40] (0-based). Which indices are probed…
- Starting from an empty stack: push 5, push 3, pop, push 8, push 2, pop, pop, push 7, push 1. What are the stack contents from top to bottom?
- A circular queue uses an array of size 5 (indices 0–4); front is the index of the first element and rear is the index of the last element…