title: BFS in binary tree
body: <p>I'm trying to write the codes for breadth-first search in binary tree. I've stored all the data in a queue, but I can't figure out how to travel to all nodes and consume all their children.</p>
  
  <p>Here's my code in C:</p>
  
  <pre><code>void breadthFirstSearch (btree *bt, queue **q) {
     if (bt != NULL) {
  
        //store the data to queue if there is
  
        if (bt-&gt;left != NULL) enqueue (q, bt-&gt;left-&gt;data);
        if (bt-&gt;right != NULL) enqueue (q, bt-&gt;right-&gt;data);
  
        //recursive
  
        if (bt-&gt;left != NULL) breadthFirstSearch (bt-&gt;left, q);
        if (bt-&gt;right != NULL) breadthFirstSearch (bt-&gt;right, q);
     }
  }
  </code></pre>
  
  <p>I've already enqueued the root data, but it's still not working.
  Can anyone point out my mistake?</p>