Sunday, September 25, 2011

Height of a Binary Tree

Function to find the height of a binary tree


int height(struct node *t)
{
  if(t == NULL)
    return 0;
  int left = height(t -> Llink);
  int right = height(t -> Rlink);
  if(left > right)
    return left + 1;
  else 
    return right + 1; 
  }
}

Written by

No comments:

Post a Comment