Lab
Binary Expression Trees
Write a program that builds a binary expression tree (BXT) from a given postfix expression, displays the expression in prefix form and evaluates it. Follow these steps in solving this problem:
- draw a BXT for each of the four given expressions; use the tree to write the expression in prefix form and evaluate it.
- fill in the five functions in the program shell "bxt.java" shown below
- copy the shell "bxt.java" and complete the program
- run your program on these four postfix expressions
12+
12+4*
432*+7-
82+591-+*
Extensions
- Display the expression in fully parenthesized infix form instead of prefix form.
- Enter the postfix expression using variables rather than numbers and ask for the values of the variables when the expression is evaluated.
- Expand the program to include other binary operations.
Continue to: Unit 8 / Prev / Next