Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- binary_tree = {"value": 2, "left":
- {
- "value": 7, "left": None, "right":
- {
- "value": 6, "left":
- {
- "value": 5, "left": None, "right": None
- }, "right":
- {
- "value": 11, "left": None, "right": None
- },
- },
- }, "right":
- {
- "value": 55, "left": None, "right": None
- }
- }
- def get_height(tree):
- if tree is None:
- return -1
- return max(get_height(tree['left']), get_height(tree['right'])) + 1
- print(get_height(binary_tree))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement