mihainan

Inaltime arbore

Jun 2nd, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.20 KB | None | 0 0
  1. int height(Tree t)
  2. {
  3.     if(t == NULL)
  4.     {
  5.         return 0;
  6.     }
  7.     else
  8.     {
  9.         int l, r;
  10.         l = height(t->left);
  11.         r = height(t->right);
  12.         if(l >= r)
  13.         {
  14.             return l+1;
  15.         }
  16.         else
  17.             return r+1;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment