You are viewing a single comment's thread. Return to all comments →
public static void levelOrder(Node root) { Queue<Node> queue = new LinkedList<>(); queue.add(root); while(!queue.isEmpty()) { Node current = queue.poll(); System.out.print(current.data+" "); if(current.left != null) queue.add(current.left); if(current.right != null) queue.add(current.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 →