Day 23: BST Level-Order Traversal

  • + 0 comments
     def levelOrder(self,root):
        queue = [root]
        for item in queue:
            if item.left:
                queue.append(item.left)
            if item.right:
                queue.append(item.right)
        print(" ".join([str(i.data) for i in queue]))