Data Structures, Algorithms, & Applications in Java
Chapter 12, Exercise 27


The code to find the tree height using a postorder traversal is given below.
public class BinaryTreeHeight
{
   /** @return tree height */
   public static int height(BinaryTreeNode t)
   {
      if (t != null)
      {// nonempty tree
         // find height of left subtree
         int hLeft = height(t.leftChild);

         // find height of right subtree
         int hRight = height(t.rightChild);

         // return overall height
         return Math.max(hLeft, hRight) + 1;
      }
      else
         return 0;
   }
}