Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int height(Node* root) {
- // Write your code here.
- if (root == NULL)
- return 0;
- // find the height of each subtree
- int lh = height(root->left);
- int rh = height(root->right);
- return max(lh,rh)+1;
- }
- int height(Node* root) {
- if (root == NULL) return 0;
- if (root ->left== NULL && root->right== NULL)
- return 0;
- // find the height of each subtree
- int lh = height(root->left);
- int rh = height(root->right);
- return max(lh,rh)+1;
- // Write your code here.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement