Skip to content

Instantly share code, notes, and snippets.

@selcukcihan
Created February 28, 2017 12:01
Show Gist options
  • Save selcukcihan/2a058e423aa09803e17953b79db63664 to your computer and use it in GitHub Desktop.
Save selcukcihan/2a058e423aa09803e17953b79db63664 to your computer and use it in GitHub Desktop.
from collections import deque
def preorder3(tree):
s = deque([tree])
s = [tree]
while s:
t = s.pop()
if t:
# print(t.value,end='')
s.append(t.right)
s.append(t.left)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment