Skip to content

Latest commit

 

History

History

Check Whether A Given Binary Tree is Perfect or Not

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given a Binary Tree, write a function to check whether the given Binary Tree is a prefect Binary Tree or not.

A Binary tree is Perfect Binary Tree in which all internal nodes have two children and all leaves are at same level.


The following tree is a perfect binary tree

               10
           /       \  
         20         30  
        /  \        /  \
      40    50    60   70


               18
           /       \  
         15         30  
The following tree is not a perfect binary tree

      1
    /    \
   2       3
    \     /  \   
     4   5    6