Guest User

Untitled

a guest
Jun 17th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. """
  2. class Node:
  3. def __init__(self, x):
  4. self.left = None
  5. self.right = None
  6. self.val = x
  7. """
  8.  
  9. def binary_tree_height(node):
  10. if not node:
  11. return 0
  12.  
  13. left_subtree_height = binary_tree_height(node.left)
  14. right_subtree_height = binary_tree_height(node.right)
  15.  
  16. return max(left_subtree_height, right_subtree_height) + 1
Add Comment
Please, Sign In to add comment