Data Structures & AlgorithmsHardProduct-company MCQ pattern
Keys 57, 11, 34, 33, 80, 9, 72, 24, 56, 66 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain) into a table of size 7 (buckets 0 to 6). What are the final bucket contents, and what is the longest chain length?
- A. 72, 57, 9, 80, 11, 33, 34 — longest chain 1
- B. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 3
- C. 56, 57, 72→9, 66→24→80, 11, 33, 34 — longest chain 3
- D. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 2
Correct answer: B. 56, 57, 9→72, 80→24→66, 11, 33, 34 — longest chain 3
Each key is appended to the chain at index k mod 7 in insertion order, giving buckets [56, 57, 9→72, 80→24→66, 11, 33, 34], whose longest chain has 3 key(s). This differs from open addressing (linear probing), which would spread keys like [72, 57, 9, 80, 11, 33, 34] into single-slot buckets instead of chains.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Undirected graph edges: B–C, C–A, E–C, E–D, E–B. Using a BFS 2-colouring, is this graph bipartite?
- Build a binary min-heap in place from the array [4, 37, 81, 88, 64, 1, 84, 86] using bottom-up heapify (sift-down from the last internal…
- An undirected graph has adjacency lists (neighbours visited in alphabetical order) A: [D, F]; B: [C, F]; C: [B, E]; D: [A, E]; E: [C, D]…
- Keys 93, 67, 60, 15, 3, 58, 52, 13, 92 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain) into…
- Build a binary min-heap in place from the array [35, 63, 89, 24, 71, 8, 16, 88, 2, 79] using bottom-up heapify (sift-down from the last…
- A binary tree has preorder traversal [52, 25, 42, 27, 64, 92, 78] and inorder traversal [25, 27, 42, 52, 64, 78, 92]. Reconstructing the…