You are viewing a single comment's thread. Return to all comments →
static int height(Node root) { if(root==null) return -1; else return height(root.left)>height(root.right)? 1+height(root.left) : 1+height(root.right); }
This works better.
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →
static int height(Node root) { if(root==null) return -1; else return height(root.left)>height(root.right)? 1+height(root.left) : 1+height(root.right); }
This works better.