Challenge: Check Completeness of Tree Using Recursion

Let’s check if a tree is complete using recursion.

Problem

Given a binary tree, find if it is a complete tree using recursion.

The tree is complete if it is filled at all possible levels except the last level. The last level is filled from left to right.

Input

A binary tree.

Output

Returns true if the tree is complete, false otherwise.

Sample input

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.