Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int height(TreeNode node)
- {
- if(node.getLeft() == null){
- if(node.getRight()==null)return 0;
- return 1+ height(node.getRight());
- }
- if (node.getRight() == null){
- if(node.getLeft()==null)return 0;
- return 1 + height(node.getLeft());
- }
- return 1 + Math.max(height(node.getLeft()), height(node.getRight()));
- }
Add Comment
Please, Sign In to add comment