Skip to content

Instantly share code, notes, and snippets.

@tmosest
Created October 9, 2016 09:03
Show Gist options
  • Save tmosest/d67c4f251fef0c6c218535ac54ec96e2 to your computer and use it in GitHub Desktop.
Save tmosest/d67c4f251fef0c6c218535ac54ec96e2 to your computer and use it in GitHub Desktop.
Hackerrank: Day 23: BST Level-Order Traversal
static void levelOrder(Node root){
Queue<Node> queue = new LinkedList();
queue.add(root);
while(!queue.isEmpty()){
Node current = queue.remove();
System.out.print(current.data+" ");
if (current.left!=null) queue.add(current.left);
if (current.right!=null) queue.add(current.right);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment