Data Structures & AlgorithmsEasyCognizant · Capgemini pattern
What is the maximum number of nodes in a binary tree of height 4, where a single-node tree has height 0?
- A. 31
- B. 15
- C. 16
- D. 32
Correct answer: A. 31
Levels 0 to 4 can hold 1 + 2 + 4 + 8 + 16 = 2⁵ − 1 = 31 nodes. 15 = 2⁴ − 1 counts only levels 0 to 3; 16 is the number of nodes at the last level alone.
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
- What is the minimum possible height of a binary tree with 100 nodes (height of a single node = 0)?
- With the edges sorted first, what is the time complexity of Kruskal's algorithm using a union-find structure, for a graph with V vertices…
- Which single-source shortest path algorithm can detect a negative-weight cycle reachable from the source?
- A topological ordering of a directed graph exists if and only if the graph is:
- A heap is stored in a 0-indexed array. What is the index of the parent of the element at index 10, and of its left child?
- Using the master theorem, what is the solution of T(n) = 2T(n/2) + n?