Check whether a given Binary Tree is Complete or not.
Given a Binary Tree, write a function to check whether the given Binary Tree is Complete Binary Tree or not.
Complete Binary Tree:
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
The approach is to do a level order traversal starting from root. In the traversal, once a node is found which is NOT a Full Node, all the following nodes must be leaf nodes. Also, one more thing needs to be checked to handle the below case: If a node has empty left child, then the right child must be empty.
Latest Source Code:
Is Tree 1 complete binary tree : true Is Tree 2 complete binary tree : true Is Tree 3 complete binary tree : true Is Tree 4 complete binary tree : false Is Tree 5 complete bin ary tree : false Is Tree 6 complete binary tree : false Is Tree 7 complete binary tree : true