This project deals with a simple kind of expression tree, where there are two kinds of nodes:
a) Leaf nodes, which contain a real number as their elements;
b) Non-leaf nodes, which contain a character which is an operation such as +,-,*,/, as their elements, and have exactly two children.
For this project, implement a class for expression trees(ExpressionTree class), including operations for building trees and traversing trees. Also include a recursive function to "evaluate" a non-empty expression tree using these rules:
a) If the tree has only one node(which must be a leaf), then the evaluation of the tree returns the real number which is the nodes element.
b) If the tree has more than one node, and the root contains +, -, *, /, then first evaluate the left subtree, then evaluate the right subtree, and then add, subtract, multiply, divide respectively, the results are returned from the left subtree evaluation, and right subtree evaluation.
For the second part of the program write a driver program that will read a file [url removed, login to view] that will be provided for you (This file will be given to you when you start coding the program). Parse each line from that file to construct an expression tree for each expression . And for each expression tree constructed, output preorder, inorder, postorder traversals of that tree together with the value of the expression tree to a file Results.txt. You should be able to construct an Expression Tree from any kind of expression: Prefix, Infix, or Postfix.
1) You can directly build a tree from Prefix.
2) You can directly build a tree from Postfix.
3) To build a tree form Infix, first convert the expression to Postfix and construct it from Postfix.
Please provide comments in the program.
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.
3) Exclusive and complete copyrights to all work purchased. (No GPL, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site).
The program should be written in java, and i use suns j2sdk version 1.4.1_01 to compile and run the code.