Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #!/usr/local/bin/python3.4
  2.  
  3. def solution(T):
  4. if T is None:
  5. return []
  6. else:
  7. result = [T[0]]
  8. if T[1] is not None:
  9. l = solution(T[1])
  10. for node in l:
  11. if node >= T[0]:
  12. result.append(node)
  13. if T[2] is not None:
  14. r = solution(T[2])
  15. for node in r:
  16. if node >= T[0]:
  17. result.append(node)
  18. return result
  19.  
  20. T = (5, (3, (20, None, None), (21, None, None)), (10, (1, None, None), None))
  21.  
  22. print(solution(T))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement