GATE Computer ScienceVery hardGATE CS (PYQ pattern)
A full binary tree has every node with 0 or 2 children; left and right are distinguished. How many structurally different full binary trees have exactly 9 leaves and height at most 4 (a single node has height 0)?
- A. 1430
- B. 470
- C. 94
- D. 158
Correct answer: C. 94
Let F(L, h) count full trees with L leaves and height <= h: F(1, h) = 1, F(L, 0) = 0 for L > 1, and F(L, h) = sum over a = 1..L-1 of F(a, h-1) F(L-a, h-1). Height <= 3 allows at most 8 leaves, so F(9, 3) = 0; computing F(9, 4) gives 94, far fewer than the unrestricted Catalan count C8 = 1430.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- An undirected unweighted graph has edges 1-2, 1-3, 2-4, 2-5, 3-4, 3-6, 4-7, 5-7, 6-7, 6-8, 7-9, 8-9. Using BFS from vertex 1, what is the…
- A directed graph on vertices 1..4 has edges 1->2, 1->3, 2->3, 2->4, 3->1, 3->4, 4->1, 4->2. How many walks of length exactly 4 (edges…
- An undirected graph has 14 vertices, 20 edges and exactly 3 connected components. DFS is restarted from an unvisited vertex until all…
- A complete binary tree stored in an array has 1000 nodes. What is its height (a single node has height 0) and how many nodes are at the…
- A binary tree with 25 nodes has two pointer fields per node. How many of these 50 fields hold NULL, and how many hold NULL if the tree is…
- A circular queue of capacity 10 (array indices 0..9) keeps front and rear indices; front is the index of the first item and rear is the…