GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Binary trees (unlabelled, left and right children distinguished) with exactly 6 nodes: how many have height exactly 3 (a single node has height 0)?
- A. 28
- B. 54
- C. 40
- D. 70
Correct answer: C. 40
Of the C6 = 132 trees, enumerating by the heights of the left and right subtrees gives 0, 0, 4, 40, 56, 32 trees of heights 0 to 5; height 5 is the 2^5 = 32 chains.
Practise more Programming and Data Structures (GATE) questionsProgramming and Data Structures (GATE): notes and key points
More Programming and Data Structures (GATE) questions
- Height is counted in edges (a single node has height 0). What is the maximum possible height of an AVL tree with 50 nodes, and what is the…
- How many distinct binary trees (left and right children are distinguished) on nodes 1..5 have preorder 1 2 3 4 5 and postorder 5 4 3 2 1?
- Among all binary trees (left and right children distinguished) with 6 nodes whose preorder traversal is 1 2 3 4 5 6, how many have an…
- A complete binary tree (every level full except possibly the last, which is filled from the left) has exactly 300 leaves. Which node…
- A rooted tree has 6 nodes with 2 children, 5 nodes with 3 children and 4 nodes with 4 children; every other node is a leaf. How many nodes…
- How many structurally different binary search trees can be built on the keys 1..7 such that the height is at most 3 (a single node has…