GATE Computer ScienceVery hardGATE CS (PYQ pattern)
How many structurally distinct AVL trees (left and right distinguished, shape only) have exactly 9 nodes?
- A. 48
- B. 38
- C. 44
- D. 1430
Correct answer: C. 44
Count shapes by height with N(n, h) = sum over left/right splits of N(l, hl) N(r, hr) where max(hl, hr) = h - 1 and |hl - hr| <= 1; summing over heights for 9 nodes gives 44.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- A binary tree is serialised in preorder with # for a null child: A B D # # E G # # # C # F # #. What is its inorder traversal and its…
- An undirected simple graph on 100 vertices is stored by keeping only the upper triangle (without the diagonal) of its adjacency matrix as…
- The 4 largest elements of the stream 14, 7, 22, 3, 18, 9, 30, 11, 25, 5, 17, 28, 2, 21 are found with a min-heap of size 4 holding the…
- A sorted array was rotated: [15, 18, 22, 25, 30, 2, 4, 7, 9, 11, 12, 14]. The standard rotated binary search (compare a[lo] <= a[mid] to…
- Two singly linked lists merge into a common tail: list X has 7 nodes before the merge point, list Y has 11 nodes before it, and the shared…
- A singly linked list 1 -> 2 -> ... -> 12 is modified by reversing the sublist from position 3 to position 9 (1-indexed, inclusive), and…