Tuesday, February 10, 2015

Binary Tree

Binary Tree: Each node in a tree can have at most 2 children. 

Property:
Leaf Node: Node with zero child.

Strict/Proper Binary Tree: Each node can have 2 or 0 children.
Complete Binary Tree: 
Balanced Binary Tree: Difference between height of left and right subtree for 
                        every node is not more than K.
Depth of Node: Length of path from root to that node.
Height of a Tree: Length of longest path between root and any of leaf nodes.

Observations:
1. Max number of nodes at level i = 2^i.
2. Max number of nodes in a Strict Binary tree = 2^(no of levels) - 1.
3. Height of a Strict Binary Tree which has N nodes = log2(n-1) -1.

Implementation:
1. Can be implemented using dynamically created nodes.
2. Arrays.


other
Binary Search Tree: Efficient structure for storing ordered data.

0 comments:

Post a Comment