title: Printing BFS (Binary Tree) in Level Order with Specific Formatting
body: <p>To begin with, this question is not a dup of <a href="https://stackoverflow.com/questions/1104644/how-would-you-print-out-the-data-in-a-binary-tree-level-by-level-starting-at-th">this one</a>, but builds on it.</p>
  
  <p>Taking the tree in that question as an example,</p>
  
  <pre><code>    1 
     / \
    2   3
   /   / \
  4   5   6
  </code></pre>
  
  <p>How would you modify your program to print it so,</p>
  
  <pre><code>1
  2 3
  4 5 6
  </code></pre>
  
  <p>rather than the general</p>
  
  <pre><code>1 
  2 
  3 
  4 
  5 
  6
  </code></pre>
  
  <p>I'm basically looking for intuitions on the most efficient way to do it - I've got a method involving appending the result to a list, and then looping through it. A more efficient way might be to store the last element in each level as it is popped, and print out a new line afterward.</p>
  
  <p>Ideas?</p>