Solution Review: Check Completeness of Tree using Recursion

Let's discuss in detail how to find if a tree is complete or not using recursion.

We'll cover the following

Solution

We can solve this problem through recursion by treating the given tree like a heap. If we consider that the parent node is present at the location index then the left child location should be at 2*index +1 and the right child location should be at 2*index +2. If it is true for every node then we have a complete tree. Letā€™s see this approach in action.

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