Skip to content

Instantly share code, notes, and snippets.

@gcapell
Created June 26, 2019 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcapell/23d4a2797589d0f5598f5b968a86639b to your computer and use it in GitHub Desktop.
Save gcapell/23d4a2797589d0f5598f5b968a86639b to your computer and use it in GitHub Desktop.
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