Challenge: Check Completeness of Tree Using Queue

Let’s check if a binary tree is complete or not.

Problem

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

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.