diff --git a/DataStructures/Trees/Tree : Height of a Binary Tree/solu.cpp b/DataStructures/Trees/Tree : Height of a Binary Tree/solu.cpp new file mode 100644 index 0000000..0413479 --- /dev/null +++ b/DataStructures/Trees/Tree : Height of a Binary Tree/solu.cpp @@ -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; + } +