Created
June 26, 2019 07:25
-
-
Save gcapell/23d4a2797589d0f5598f5b968a86639b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, val, left, right): | |
self.val = val | |
self.left = left | |
self.right = right | |
t = Node(3, | |
Node(2, | |
Node(1,None,None), | |
Node(2.5, None, None), | |
), | |
Node(4, | |
Node(3.5, None, None), | |
Node(5,None,None), | |
) | |
) | |
def inorder(n): | |
if n is None: | |
return | |
yield from inorder(n.left) | |
yield n.val | |
yield from inorder(n.right) | |
for v in inorder(t): | |
print(v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment