Day 23: BST Level-Order Traversal

  • + 0 comments
        def levelOrder(self,root):        
            nodes = list()        
            nodes.append(root)
            
            for e in nodes:                
                print(e.data, end = " ")    
                     
                if e.left is not None:
                    nodes.append(e.left)            
                if e.right is not None:
                    nodes.append(e.right)