Guest User

Untitled

a guest
May 27th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. public int height(TreeNode node)
  2. {
  3. if(node.getLeft() == null){
  4. if(node.getRight()==null)return 0;
  5. return 1+ height(node.getRight());
  6. }
  7. if (node.getRight() == null){
  8. if(node.getLeft()==null)return 0;
  9. return 1 + height(node.getLeft());
  10. }
  11. return 1 + Math.max(height(node.getLeft()), height(node.getRight()));
  12. }
Add Comment
Please, Sign In to add comment