title: How to print entries of AVLTree in Pre-order Traversal
body: <p>I am trying to print the objects stored in the AVL Tree using preorder Traversal, the program runs fine but it does not print the preorder traversal it just prints the objects in the order they were inserted into the tree. can anyone help me with it?</p>
  
  <pre><code>private AVLNode&lt;AnyType&gt; printPreorder(AVLNode&lt;AnyType&gt; t) {
          if (t == null)
              return null;
  
          /* first print data of node */
          System.out.print(t.element + " ");
  
          /* then recur on left sutree */
          printPreorder(t.left);
  
          /* now recur on right subtree */
          printPreorder(t.right);
          return null;
  
      }
  
  
      public AVLNode&lt;AnyType&gt; print() {
          return printPreorder(root);
      }
  </code></pre>