We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Tree: Level Order Traversal
Tree: Level Order Traversal
Sort by
recency
|
562 Discussions
|
Please Login in order to post a comment
I used the following code:
def levelOrder(root): if root is None: return q = [root] while(len(q) > 0): n = q.pop(0) print(n.info, end = ' ') if n.left: q.append(n.left) if n.right: q.append(n.right)
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )
JavaScript :
def levelOrder(root):
1. ## a.append(c.right)