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