What is a perfect binary tree?
a) A binary tree where all levels are completely filled
b) A binary tree with only one level
c) A binary tree with no leaf nodes
d) A binary tree with an equal number of left and right nodes
Answer:
a) A binary tree where all levels are completely filled
Explanation:
A perfect binary tree is a binary tree in which all internal nodes have exactly two children, and all leaf nodes are at the same level. In other words, every level of the tree is completely filled with nodes.
Perfect binary trees have a well-defined structure, and their height is minimal given the number of nodes. For a perfect binary tree with height h, the number of nodes is 2^(h+1) – 1.
Perfect binary trees are used in algorithms and applications where the structure needs to be balanced and evenly distributed, such as in heap-based priority queues.
Reference:
DSA (Data Structures and Algorithms) MCQ Questions and Answers