GATE Computer ScienceVery hardGATE CSE
How many structurally distinct binary search trees on 6 keys have height exactly 3, where height is the number of edges on the longest root-to-leaf path?
- A. 40
- B. 48
- C. 34
- D. 44
Correct answer: A. 40
Count shapes with height ≤ 3 and subtract those with height ≤ 2: 44 − 4 = 40.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- In how many different ways can the keys 1, 2, …, 7 be arranged in the array of a binary max-heap (every parent greater than its children)?
- A binary max-heap is built from 15 elements by Floyd's bottom-up method (sift-down from the last internal node to the root). Each level of…
- int A(int m, int n) { if (m == 0) return n + 1; if (n == 0) return A(m - 1, 1); return A(m - 1, A(m, n - 1)); } How many times is A…
- Thirteen people numbered 1 to 13 stand in a circle (circular linked list). Starting the count at person 1 (who counts as 1), every 4th…
- A disjoint-set forest over elements 1..8 starts with each element as its own root. It uses union by rank (on equal ranks, the root of the…
- On a machine where char needs 1-byte, short 2-byte and int 4-byte alignment (each member at the next offset divisible by its own size, and…