title: Trying to display a Tree
body: <p>I'm in the middle of writing a program that could display a family tree where children are to the left and their sibling are to the right. Such a tree would look like the following:</p>
  
  <pre><code>                              gradfather
                               /       \
                              child     gradfathers sibling
                             /    \
                 childs child      childs first sibling
                                    \
                                     childs second sibling etc
  </code></pre>
  
  <p>I know it may be a little weird but I'm trying to practice graphs.  Anyway, I'm trying to write a method that could display the tree and I'm not quite sure if my logic is correct.  My code is as follows</p>
  
  <pre><code>public void printTree() {
      Node current = root;
      Node parent;
      while (current.left != null) {
          System.out.print("Great-Great Gradfather is: " + root);
          current = current.left;
          parent = current;
          if (current.right != null) {
              System.out.print("His children are: ");
              while (current.right != null) {
                  System.out.print(current + " ");
                  current = current.right;
              }
          }
          current = parent;
          current = current.left;
          parent = current;
      }
  }
  </code></pre>
  
  <p>The output I am looking to get would be </p>
  
  <pre class="lang-none prettyprint-override"><code>your Great grandfather was name
  
  his children were names
  
  they're children were names
  
  your siblings are names
  </code></pre>
  
  <p>would it be more efficient to write a more simple print function that displays the 'current' root at the time and just the siblings, and in my main do a <code>System.out.print</code> saying "their children are" and then printing.  Like maybe iterate the current to <code>current.left</code> everytime?  Or am I on the right track with one large print method? </p>
  
  <p>Thanks guys.</p>