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

Get hands-on with 1400+ tech skills courses.