Skip to content

Instantly share code, notes, and snippets.

@kagan94
Last active September 27, 2016 13:53
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 kagan94/6e3b250cd28979fe3e7304ca285fab0b to your computer and use it in GitHub Desktop.
Save kagan94/6e3b250cd28979fe3e7304ca285fab0b to your computer and use it in GitHub Desktop.
Breadth-first output of the b-tree
def depth_first(self, root):
Q = [root]
elems = []
while len(Q):
current = Q.pop(0)
elems.append(current.data)
if current.left is not None:
Q.append(current.left)
if current.right is not None:
Q.append(current.right)
print(*elems)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment