Data Structures & AlgorithmsVery hardGATE CS · ICPC regional · Product Company SDE
What is the minimum number of nodes in an AVL tree of height 2 (height of a single node = 0)?
- A. 4
- B. 3
- C. 6
- D. 2
Correct answer: A. 4
N(h) = N(h−1) + N(h−2) + 1 with N(0)=1, N(1)=2 → 1, 2, 4; N(2) = 4.
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
- Keys 92, 32, 23, 59, 88, 36, 57, 46, 30 are inserted in this order into an empty BST. How many nodes lie in the left subtree of the root 92?
- An undirected graph has edges (u–v: weight) A–B:7, A–C:12, C–D:14, D–E:15, E–F:2, F–B:23, A–E:17, D–A:29. What is the weight of its…
- In the undirected graph with edges A–B:4, A–C:9, B–D:8, B–E:10, E–F:2, C–D:4, F–A:8, E–D:11, what is the shortest-path distance from A to C?
- A forest has 27 vertices and 2 connected components (trees). How many edges does it have?
- Keys 12, 33, 64, 60, 24, 16, 31 are inserted one by one into an empty binary search tree. What is the pre-order traversal?
- Keys 76, 95, 23, 92, 94, 56, 15, 57, 87 are inserted in this order into an empty BST. How many leaf nodes does the tree have?