title: Java Breadth First Search using Queue
body: <p>I have build two classes in Java to traverse Breadth First Search. The <code>Node class</code> as: </p>
  
  <pre><code>public class Node {
    Node left;
    Node right;
    int value;
  
  public Node(int value2) {
  // TODO Auto-generated constructor stub
    this.value = value2;
   }
  </code></pre>
  
  <p>The BreadthFirst Search <code>method</code> in <code>SerachClass</code>includes the following <code>code</code> </p>
  
  <pre><code>  public void breadthFS(Node root) {
      // TODO Auto-generated method stub
  
            Queue&lt;Node&gt; bfs=new LinkedList&lt;Node&gt;();
  
            if (root==null)
            {
                return; 
            }
            else 
            {
                bfs.clear();
                bfs.add(root);
                while(!bfs.isEmpty())
                {
                    Node current=bfs.remove();
                    System.out.println("The breadth first search"+current.value);
                    }
                    if (root.left!=null) bfs.add(root.left);
                    if (root.right!=null) bfs.add(root.right);
              }
            }
  </code></pre>
  
  <p>Then, I have inserted the following values {6,2,1,3,10,9,11}. The output will be in a loop such that: </p>
  
  <pre><code>The breadth first search 6
  The breadth first search 2
  The breadth first search 6
  The breadth first search 2
  The breadth first search 6
  ...
  </code></pre>
  
  <p>I will appreciate your help and comments. </p>