Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3.4
- def solution(T):
- if T is None:
- return []
- else:
- result = [T[0]]
- if T[1] is not None:
- l = solution(T[1])
- for node in l:
- if node >= T[0]:
- result.append(node)
- if T[2] is not None:
- r = solution(T[2])
- for node in r:
- if node >= T[0]:
- result.append(node)
- return result
- T = (5, (3, (20, None, None), (21, None, None)), (10, (1, None, None), None))
- print(solution(T))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement