Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Albero:
- def __init__(self,val):
- self.val = val
- self.sx = None
- self.dx = None
- a = Albero(4)
- b = Albero(1)
- c = Albero(2)
- d = Albero(6)
- a.dx = d
- a.sx = b
- b.dx = c
- def inorder(a,l):
- if a.sx != None:
- inorder(a.sx,l)
- l.append(a.val)
- if a.dx != None:
- inorder(a.dx,l)
- def preorder(a):
- print(a.val)
- if a.sx != None:
- inorder(a.sx)
- if a.dx != None:
- inorder(a.dx)
- def postorder(a):
- if a.sx != None:
- inorder(a.sx)
- if a.dx != None:
- inorder(a.dx)
- print(a.val)
- l = []
- inorder(a,l)
Advertisement
Add Comment
Please, Sign In to add comment