Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Tree_height(Node* node)
- {
- Node *htemp = node;
- int lcounter = 0;
- int rcounter = 0;
- if (node == NULL)
- {
- return 0;
- }
- if (htemp->left != NULL)
- {
- lcounter = Tree_height(htemp->left)+1;
- }
- if (htemp->right != NULL)
- {
- rcounter = Tree_height(htemp->right)+1;
- }
- if (lcounter > rcounter)
- {
- return (lcounter);
- }
- else
- {
- return (rcounter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement