Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions DataStructures/Trees/Tree : Height of a Binary Tree/solu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

/*The tree node has data, left child and right child
class Node {
int data;
Node* left;
Node* right;
};

*/
int height(Node* root) {
// Write your code here.
if(root == NULL){
return -1;
}
int left = height(root->left);
int right = height(root->right);
int max = left > right ? left : right;
return max+1;
}