GATE Computer ScienceModerateGATE CSE
How many structurally distinct binary search trees can be built from 7 distinct keys?
- A. 132
- B. 430
- C. 429
- D. 5040
Correct answer: C. 429
The count is the Catalan number C7 = (1/8)·C(14,7) = 429.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- An AVL tree of height 6 (a single node has height 0) must contain at least how many nodes?
- Keys 12, 7, 19, 3, 25, 9, 14 are inserted one by one into an initially empty max-heap stored in an array (index 0 is the root), each…
- An 11-slot hash table with h(k) = k mod 11 and linear probing receives keys 23, 34, 45, 12, 56, 67, 78 in that order. In which slot (0–10)…
- int a[6] = {2, 4, 6, 8, 10, 12}; int p = a + 1, q = a + 5; What does printf("%ld %d", (long)(q - p), (p + (q - p) / 2)); print?
- int f(int n) { if (n < 2) return 1; return f(n - 1) + f(n - 2); } Including the initial call, how many times is f invoked while evaluating…
- A queue is implemented with two stacks: ENQ pushes onto stack S1; DEQ pops from S2, and if S2 is empty it first moves every element of S1…