Created
April 17, 2021 07:55
-
-
Save leejh3224/64775bdd2e09ce9506fc72adcbdd5618 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
def level_bfs(): | |
queue = [] | |
queue.append(root) | |
while queue: | |
size = len(queue) | |
node = queue.pop(0) | |
while size: | |
if node.left: | |
queue.append(node.left) | |
if node.right: | |
queue.append(node.right) | |
# end of each level |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment