You are viewing a single comment's thread. Return to all comments →
it all depends on the traversal. If you are using -1, code would be
if(head==NULL) return -1; int leftcount= 1+height(root->left);
now, if you want to use 0 then, code would be
if(head==NULL) return 0; if(root->left!=NULL) int leftcount= 1+height(root->left);
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →
it all depends on the traversal. If you are using -1, code would be
now, if you want to use 0 then, code would be