Last active
September 27, 2016 13:53
-
-
Save kagan94/6e3b250cd28979fe3e7304ca285fab0b to your computer and use it in GitHub Desktop.
Breadth-first output of the b-tree
This file contains hidden or 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
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