Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cercavalore(a, k):
- if a is None:
- return False
- if a.val == k:
- return True
- if a.sx is None a.dx is None:
- return False
- cercasx = False
- cercadx = False
- if a.sx is not None:
- cercasx = cercavalore(a.sx, k)
- if a.dx is not None:
- cercadx = cercavalore(a.dx, k)
- return cercasx or cercadx
- def cercavalore2(a,k):
- if a is None:
- return False
- if a.val == k:
- return True
- return cercavalore2(a.sx,k) or cercavalore2(a.dx,k)
Advertisement
Add Comment
Please, Sign In to add comment