Advertisement
Guest User

height new

a guest
Mar 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. int  Tree_height(Node* node)
  2. {
  3.     Node *htemp = node;
  4.     int lcounter = 0;
  5.     int rcounter = 0;
  6.    
  7.     if (node == NULL)
  8.     {
  9.         return 0;
  10.     }
  11.  
  12.     if (htemp->left !=  NULL)
  13.     {
  14.         lcounter = Tree_height(htemp->left)+1;
  15.     }
  16.     if (htemp->right != NULL)
  17.     {
  18.         rcounter = Tree_height(htemp->right)+1;
  19.     }
  20.     if (lcounter > rcounter)
  21.     {
  22.         return (lcounter);
  23.     }
  24.     else
  25.     {
  26.         return (rcounter);
  27.     }
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement