You are viewing a single comment's thread. Return to all comments →
static void levelOrder(Node root){
//Write your code here Queue<Node> queue = new LinkedList<>(); queue.add(root); while(!queue.isEmpty()) { Node node =queue.remove(); System.out.print(node.data+" "); if(node.left != null) { queue.add(node.left); } if(node.right != null) { queue.add(node.right); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →
****java 7*
static void levelOrder(Node root){