The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. 
Home Trees Expression Trees  
See also: Postfix Expressions  
Expression Trees
The following figure represents the same computation: The nodes can be operands like 1 and 2 or operators like + and *. Operands are leaf nodes; operator nodes contain references to their operands (all of these operators are binary, meaning they have exactly two operands). Looking at this figure, there is no question what the order of operations is: the multiplication happens first in order to compute the first operand of the addition. Expression trees like this have many uses. The example we are going to look at is translation from one format (postfix) to another (infix). Similar trees are used inside compilers to parse, optimize and translate programs.


Home Trees Expression Trees 