title: Tree traversal, reading the code
body: <p>I was looking up tree traversal and so far i had no problems understanding it, meaning pre-order, in-order, post-order. And the simple code like:</p>
  
  <pre><code>sub P(TreeNode)
  Output(TreeNode.value)
  If LeftPointer(TreeNode) != NULL Then
     P(TreeNode.LeftNode)
  If RightPointer(TreeNode) != NULL Then
     P(TreeNode.RightNode)
  end sub
  </code></pre>
  
  <p>i found a code that is longer and i got confused, what will be the output?</p>
  
  <pre><code>public class My {
   public static void print(Node n){
      if(n != null) {
         System.out.print(n.info +"");
         print(n.left);
         print(n.right);
      }
  } 
   public static void print2(Node n){
      if(n != null) {           
         print2(n.left);
         System.out.print(n.info +"");
         print2(n.right);
      }
   }
  
   public static void print3(Node n){
      if(n != null) {           
         print3(n.left);
         print3(n.right);
         System.out.print(n.info +"");           
      }
  }
  public static void main(String[] args) {
  Tree t = new Tree();
     t.createTree();
     print(t.root);
     System.out.println();
     print2(t.root);
     System.out.println();
     print3(t.root);
  }
  } 
  </code></pre>
  
  <p>and so just its easier for me to understand lets say that the input is 10,-10,12,8,21,34<br>
  whats will the output look like? because if i understood correctly then there are all 3 (pre-order, in-order, post-order).</p>
  
  <p>tree will look like : </p>
  
  <pre><code>     10
  -10     12
  8  21  34
  </code></pre>
  
  <p>turns out this is exam in one of my schools and they have to give the answer one the paper, and this is all the information they get. No one tells them how the tree will look.</p>