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