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": 5, "left": None, "right": None
- }
- }
- def get_leafes(tree):
- if tree == None:
- return
- get_leafes(tree["left"])
- if tree['left'] == None and tree['right'] == None:
- print(tree['value'])
- get_leafes(tree["right"])
- print(get_leafes(binary_tree))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement