Charles Cole

Greenhorn

Posts: 9

posted 3 years ago

Write a Java program to create a binary expression tree in which: leaves are (double) numbers, and interior

nodes are binary algebraic operators). As an example, the expression 1 2 + 3 * could be represented as:

The input to the program is an arithmetical expression (already) in postfix notation. Use for testing the sample :

4 8 2 / * 10 7 ‐ + ( equivalent to 4*8/2+(10‐7) ) .

After creating the corresponding expression tree, print it’s traversal in Pre‐Order, In‐Order, and Post‐Order.

Evaluate the expression and print its final value (for this example, result should be: 19.00).

I'm not really certain how I would go about solving this problem, can anyone help me get started and guide me in the right direction?

nodes are binary algebraic operators). As an example, the expression 1 2 + 3 * could be represented as:

The input to the program is an arithmetical expression (already) in postfix notation. Use for testing the sample :

4 8 2 / * 10 7 ‐ + ( equivalent to 4*8/2+(10‐7) ) .

After creating the corresponding expression tree, print it’s traversal in Pre‐Order, In‐Order, and Post‐Order.

Evaluate the expression and print its final value (for this example, result should be: 19.00).

I'm not really certain how I would go about solving this problem, can anyone help me get started and guide me in the right direction?