Contents    Page-10    Prev    Next    Page+10    Index   

Trees and Reverse Polish

It is easy to convert a tree representation to RPN by a postorder recursive algorithm:

  1. If the expression to be converted is an operand (leaf node), put it into the output.

  2. Otherwise, the expression is a subtree. Convert the left-hand operand, then convert the right-hand operand, then put the operator into the output.