Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public void levelOrder(Node<Character> n)
  2. {
  3. LinkedList<Character> l1 = new LinkedList<Character>();
  4. LinkedList<Character> lfinal = new LinkedList<Character>();
  5.  
  6. l1.addFirst(n.cont); // head
  7. Node<Character> x = n;
  8. while(!l1.isEmpty())
  9. {
  10. if(x.left != null)
  11. l1.add(x.left);
  12.  
  13. if(x.right != null)
  14. l1.add(x.right);
  15.  
  16. lfinal.add(l1.getFirst());
  17. l1.removeFirst();
  18. x = l1.getFirst();
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement