Recursive solution:
Termination condition : treenode==null
1. Find the height of left subtree
2. Find the height of the right sub tree
if height of left subtree is larger
height=height of left subtree +1
else
height=height of right subtree +1
Termination condition : treenode==null
1. Find the height of left subtree
2. Find the height of the right sub tree
if height of left subtree is larger
height=height of left subtree +1
else
height=height of right subtree +1
No comments:
Post a Comment