Data Structures & AlgorithmsEasyTCS NQT · Wipro pattern
A full binary tree (every node has 0 or 2 children) has 10 internal nodes. How many leaves does it have?
- A. 11
- B. 10
- C. 20
- D. 9
Correct answer: A. 11
In a full binary tree, leaves = internal nodes + 1 (each internal node adds two child slots, and every node except the root fills one). 10 + 1 = 11. '20' counts the child slots, not the leaves.
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
- An undirected graph with V vertices and E edges is stored as adjacency lists. How many entries do all the lists hold in total?
- Which traversal should be used to free every node of a binary tree, so that no node is freed before its children?
- Keys 40, 20, 60, 10, 30, 50, 70, 25 are inserted into an empty BST. Then 20 is deleted (a node with two children is replaced by its…
- A 3-ary (ternary) heap is stored in a 0-indexed array where node i has children 3i + 1, 3i + 2 and 3i + 3. What is the index of the parent…
- An undirected graph has edges A–B, A–C, B–D, C–D, C–E, D–F, E–G, F–G, G–H. How many vertices are at a shortest distance of EXACTLY 2 edges…
- A graph has 9 vertices and 3 connected components. How many edges does a minimum spanning FOREST (an MST of every component) contain?