I'm making a Postfix calculator where I must use stack objects and a Binary tree during the translation of an expression from infix to a parse tree during the evaluation of a postfix expression.
Can someone please translate?
I have developed a postfix calculator method and I've developed a method that changes an expression from infix to postfix, but I don't understand what I am being asked to do. I can enter an expression in infix and calculate it fine as well as convert it to postfix, but I cannot determine what exactly I am being asked to create here.
An example of how to essentially do this in pseudocode would be very helpful or just an explanation of how to store a mathematical expression into a binary tree as well as how to evaluate an expression in a binary tree with stack into a parse tree.
I'll also say I'm a little unsure what a parse tree is.
Any explanation would be very much appreciated.
It is an assignment for a class, so it can be seen here if this was inadequate information: http://www.cs.gsu.edu/jbhola/csc3410/Spring13/assign6_expre_tree.html
My main point here is I just don't quite understand what I'm supposed to do or how I'm supposed to do it. We weren't taught how to program any of this and we lack a textbook so I'm just kind of blindly trying to wrap my head around the whole project :/
Imagine you have a node like AddNode which has two values
class AddNode {
final double a, b;
double value() {
return // how could you return the value of this node?
}
}
Making it more generic
interface Node { double value(); }
class AddNode implements Node {
final Node a, b;
double value() {
return // something which gives the value of this node.
}
}