Data Structures & AlgorithmsVery hardProduct-company MCQ pattern
Keys 34, 69, 39, 53, 61, 76, 35 are inserted in this order into an empty BST (no rebalancing). What is the height of the tree (edges on the longest root-to-leaf path)?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: A. 4
Inserting keys in this order without rebalancing produces a tree whose deepest leaf is 4 edges below the root. 2 would be the height of a *balanced* tree with 7 nodes, which insertion order alone does not guarantee.
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
- An undirected graph has adjacency lists (neighbours visited in alphabetical order) A: [C, E, F]; B: [C, E]; C: [A, B, F]; D: [F]; E: [A…
- An undirected graph has adjacency lists (neighbours visited in alphabetical order) A: [B, C, F]; B: [A, C, D]; C: [A, B]; D: [B, E, F]; E…
- What are the time complexities of P and Q? c int P(int n) { if (n <= 1) return 1; return P(n/2) + P(n/2) + n; } int Q(int n) { if (n <= 1)…
- Undirected graph edges: E–D, E–C, A–C, D–C, B–A, B–E, B–D. Using a BFS 2-colouring, is this graph bipartite?
- Keys 69, 79, 89 are inserted in this order into an empty AVL tree. After AVL rebalancing (a single rotation resolves the imbalance here)…
- Keys 4, 74, 93, 84, 37, 87, 63 are inserted via separate chaining (h(k) = k mod 7, new keys appended to the end of the chain) into a table…