What is the height of a complete binary tree with n nodes?

What is the height of a complete binary tree with n nodes?

a) O(n)
b) O(log n)
c) O(n log n)
d) O(1)

Answer:

b) O(log n)

Explanation:

The height of a complete binary tree with n nodes is O(log n). In a complete binary tree, all levels except possibly the last are completely filled, and the last level is filled from left to right.

The height of a complete binary tree is determined by the number of levels, which is proportional to log n, where n is the total number of nodes in the tree.

This logarithmic height allows efficient searching, insertion, and deletion operations in binary trees, particularly in balanced binary trees such as AVL and Red-Black trees.

Reference:

DSA (Data Structures and Algorithms) MCQ Questions and Answers

Scroll to Top