Data Structures & AlgorithmsModerateGATE CSE · Trees
How many structurally different binary search trees can be built from 5 distinct keys?
- A. 32
- B. 120
- C. 42
- D. 14
Correct answer: C. 42
The count is the Catalan number C5 = (1/6) x C(10,5) = 42.
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
- A DAG has edges A->C, A->D, B->D, C->E, D->E, D->F, E->G, F->G. Using Kahn's algorithm and always removing the alphabetically smallest…
- In the directed graph with edges S->A (4), S->B (1), B->A (2), A->C (5), B->C (8), B->D (10), C->D (2), C->T (6), D->T (3), what is the…
- A connected undirected graph has 9 vertices and 14 edges. What is the minimum number of edges that must be removed to turn it into a…
- Keys 10, 20, 30, 40, 50, 25 are inserted in this order into an empty AVL tree. What is the preorder traversal of the final tree?
- Keys 9, 4, 7, 1, 8, 2, 6 are inserted one at a time into an empty min-heap (array representation). Two delete-min operations are then…
- Edges of an undirected weighted graph: A-B 7, A-D 5, B-C 8, B-D 9, B-E 7, C-E 5, D-E 15, D-F 6, E-F 8, E-G 9, F-G 11. What is the weight…