Tree: Height of a Binary Tree

  • + 1 comment

    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);