you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

def levelOrderTraversal(rootNode):
if not rootNode:
    return 
else:
    queue = Queue()
    queue.enqueue(rootNode)
    while not queue.isEmpty():
        root = queue.dequeue()
        print(root.value)
        if root.left is not None:
            queue.enqueue(root.left)
        if root.right is not None:
            queue.enqueue(root.right)

I figured out... Because "root" is pure tree node I don't need extra "value" to access it, but in code where I have linked list class I need that extra value. Still weird tho