Austin Mauldin
Austin Mauldin

Reputation: 315

How is this a complete binary tree

I'm going over some data structures work and thought I understood complete binary trees which are defined as:

is a binary tree of depth n such that it has all possible nodes on level 0 to n-1, and all leaf nodes on level n occupy the most left positions on that level.

However, the following image has me confused about my understanding of the topic:

this image

If this is a complete binary tree, why does it not need two child nodes in the right subtree?

Would the definition not imply that the right subtree needs two children to be complete or does it not have to be since that child would be on the bottom level of this tree?

Upvotes: 0

Views: 159

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170899

If this is a complete binary tree, why does it not need two child nodes in the right subtree?

Because neither of the two conditions requires it? It has all nodes on level 0 and 1, and the leaf nodes on level 2 are on the left (e.g. if the right node on level 1 had only the right child, this wouldn't hold).

Upvotes: 1

Related Questions