You are viewing a single comment's thread. Return to all comments →
@aniruth_prata22 was right. I don't understand why someone have down voted his answer....
void levelOrder(Node root) { Queue<Node> queue=new LinkedList<>(); queue.add(root); while(!queue.isEmpty()) { Node tempNode=queue.poll(); System.out.print(tempNode.data+" "); if(tempNode.left!=null) queue.add(tempNode.left); if(tempNode.right!=null) queue.add(tempNode.right); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
@aniruth_prata22 was right. I don't understand why someone have down voted his answer....