Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to get the height of a tree
- int tree_height(treeNode* root) {
- if(!root) return 0;
- return 1 + max(tree_height(root->left), tree_height(root->right);
- }
- // Function to get the size of a tree
- int tree_size(treeNode* root) {
- if(!root) return 0;
- return tree_size(root->left) + 1 + tree_size(root->right);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement