title: Binary tree Breadth-first search
body: <p>I'm using OCaml. I have type:   </p>
  
  <pre><code>type 'a bt = Empty | Node of 'a * 'a bt * 'a bt;;
  </code></pre>
  
  <p>Also I have example BST:</p>
  
  <pre><code>let tree = Node(1,Node(2,Node(4,Empty,Empty),Empty),Node(3,Node(5,Empty,Node(6,Empty,Empty)),Empty));
  </code></pre>
  
  <p>I need to write function: <code>breadthBT : 'a bt -&gt; 'a list</code> which will be Breadth-first search traversal. For above example tree it should returns <code>[1; 2; 3; 4; 5; 6]</code></p>
  
  <p>How to write that function? I can write only following function which uses <strong>DST</strong> :</p>
  
  <pre><code>let rec breadthBT tree =
  if tree=Empty then []
  else let Node(w,l,r)=tree in (w::breadthBT l)@breadthBT r;;
  </code></pre>
  
  <p>Above function returns (for example tree) [1; 2; 4; 3; 5; 6]. But I can't write function which uses <strong>BFS</strong>. Could you help me?</p>