[英]Binary Tree Postfix Calculator
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. 我正在制作一个Postfix计算器,在对Postfix表达式求值时,将表达式从中缀转换为解析树时,必须使用堆栈对象和Binary树。
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.
我可以在infix中输入一个表达式,然后对其进行精确计算以及将其转换为postfix,但是我无法确定要在此处创建的确切内容。
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 这是一个班级的作业,因此如果信息不足,可以在这里看到: 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 假设您有一个像AddNode这样的节点,它有两个值
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.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.