Back to problems

Validate complete binary tree

Algorithm · Meta · Medium

You receive the root node of a binary tree. A tree is called complete when it satisfies both of the following conditions: Every level, except possibly the last one, is entirely filled. On the last level, nodes are placed as far to the left as possible. Write a function that returns true when the tree is complete and false when it is not. For the examples, each tree is written as [value, left, right], where left and right are either null or another nested tree of the same…

Checking your access…