Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Given a Binary Tree, find density of it by doing one traversal of it.

Density of Binary Tree = Size / Height 

Input: Root of following tree
   10
  /   \
 20   30

Output: 1.5
Height of given tree = 2
Size of given tree = 3

Input: Root of following tree
     10
    /   
   20   
 /
30
Output: 1
Height of given tree = 3
Size of given tree = 3