Data Structures & AlgorithmsModerateTCS NQT · Trees
What is the maximum number of nodes in a binary tree of height 5, where the height is the number of edges on the longest root-to-leaf path?
- A. 31
- B. 32
- C. 64
- D. 63
Correct answer: D. 63
A full binary tree of height h has 2^(h+1) - 1 nodes, so 2^6 - 1 = 63.
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 complete binary tree stored level by level has exactly 40 nodes. How many of them are leaves?
- Keys 14, 8, 11, 5, 9, 3, 12 are inserted one at a time into an initially empty binary min-heap kept in an array. What does the array hold…
- An undirected graph has edges A-B, A-C, B-D, B-E, C-E, C-F, D-G, E-G, F-G. Neighbours are always visited in alphabetical order. What is…
- A binary tree has inorder traversal D B E A F C and postorder traversal D E B F C A. What is its preorder traversal?
- How many structurally different binary search trees can be built from 5 distinct keys?
- 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…