Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arbore = { "value" : 8,
- "left":
- {
- "value": 9, "left":
- {
- "value": 3, "left":
- {
- "value": 14, "left": None, "right": None
- }, "right":
- {
- "value": 2, "left": None, "right":
- {
- "value": 5, "left": None, "right": None
- }
- }
- }, "right": None
- },
- "right":
- {
- "value": 20, "left":
- {
- "value": 7, "left": None, "right": None
- }, "right":
- {
- "value": 15, "left":
- {
- "value": 30, "left":
- {
- "value": 22, "left": None, "right": None
- }, "right":
- {
- "value": 27, "left": None, "right": None
- }
- }, "right": None
- }
- }
- }
- def printTree(tree, level = 0):
- if tree is None:
- return
- print(' ' * level * 2 + str(tree['value']))
- printTree(tree['left'], level + 1)
- printTree(tree['right'], level + 1)
- printTree(arbore)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement