Description: 表达式类型的实现:
1、 一个表达式和一颗二叉树之间,存在着自然的对应关系。
2、 假设算术表达式Expression内可以含有变量(a~z)、常量(0~9)和二元运算符(+,-,*,/,^)。实现一下操作。
(1) ReadExpr(E)——以字符序列的形式输入语法正确的前缀表示式并构造表达式E。
(2) WritrExpr(E)——用带括弧的中缀表示式输出表达式E。
(3) Assign(V,c)——实现对变量V的赋值(V=c),变量的初值为0。
(4) Value(E)——对算术表达式E求值。
(5) CompoundExpr(P,E1,E2)——构造一个新的复合表达式(E1)P (E2)。
-Realize the type of expression: one, an expression, and between a binary tree, there is a natural correspondence between. 2, assuming that the arithmetic expression Expression can contain variables (a ~ z), constant (0 ~ 9) and binary operators ( ,-,*,/,^)。 You realize the operation. (1) ReadExpr (E)- sequence of characters in the form of input grammar correct prefix expressions and tectonic expression of E. (2) WritrExpr (E)- used within parentheses express output infix expression E. (3) Assign (V, c)- realize the value V of the variables (V = c), variable initial value is 0. (4) Value (E)- on the arithmetic expression E is evaluated. (5) CompoundExpr (P, E1, E2)- Construction of a new composite expression (E1) P (E2). Platform: |
Size: 58368 |
Author: |
Hits:
Description: (1)利用二叉树来计算公式的真值。首先利用堆栈将中缀形式的公式变为后缀形式;然后根据后缀形式,从叶结点开始构造相应的二叉树;最后按后序遍历该树,求各子树之值,即每到达一个结点,其子树之值已经计算出来,当到达根结点时,求得的值就是公式之真值。
(2)逻辑变元的标识符不限于单字母,而可以是任意长的字母数字串。
(3)根据用户的要求显示表达式的真值表。
-(1) the use of binary tree to calculate the formula for the true value. Stack will be the first to use infix form of the formula into the form of the suffix and then form the basis of the suffix from the beginning of leaf nodes corresponding binary tree structure Finally after by traversal of the tree, and the value of the subtree, that is, for every arrival a node, the value of its sub-tree has been calculated, when the reach the root node, the obtained value is the formula of true value. (2) logical variables are not limited to single-letter identifier, which can be arbitrarily long alphanumeric string. (3) In accordance with the requirements of users showed that expression of the truth table. Platform: |
Size: 7168 |
Author:hillary |
Hits:
Description: 中缀表达式转后缀表达式,建立二叉表达式树,利用二叉表达式树求解
-Infix to suffix expressions expression, the establishment of binary expression tree, the use of binary expression tree to solve Platform: |
Size: 1024 |
Author:李 |
Hits:
Description: 前缀表达式转换成二叉树的代码,通过转换成二叉树可以轻松实现转换成后缀,前缀,中缀形式。-Prefix expression into a binary tree code, through the binary tree can be converted easily into a suffix, prefix, infix form. Platform: |
Size: 3072 |
Author:wxg |
Hits:
Description: 中缀表达式改后缀表达式,同过先建立表达式树,再对其进行后序遍历-Infix to suffix expressions expressions have to create the same expression tree, and then after its traversal Platform: |
Size: 1016832 |
Author:sangzhi |
Hits:
Description: 算术表达式与二叉树之间存在着对应关系,编写把以前缀形式输入的合法算术表达式转换为中缀表达式,再转换为后缀表达式,并求表达式的值-Arithmetic expressions with binary tree there is a correlation between the preparation of the form to enter the legitimate prefix arithmetic expression conversion infix expression, and then converted to suffix expressions and expressions for the value of Platform: |
Size: 1024 |
Author:ty |
Hits:
Description: 中缀表达式转后缀,生产表达式二叉树并在控制台中画出
-Switch to postfix infix expression, production and expression binary tree drawn in the console Platform: |
Size: 1073152 |
Author:戈润栋 |
Hits:
Description: 一个表达式和一棵二叉树之间,存在着自然的对应关系。写一个程序,实现基于二叉树表示的算术表达式Expression的操作。
【基本要求】
【一】【必做部分】
假设算术表达式Expression内可以含有变量(a-z),常量(0-9)和二元运算符(+,-,*,/,^(乘幂))。实现以下操作:
(1)ReadExpr(E)――以字符序列的形式输入语法正确的前缀表达式并构造表达式E。
(2)WriteExpr(E)――用带括号的中缀表达式输出表达式E。
(3)Assign(V,c)――实现对变量V的赋值(V=c),变量的初值为0。
(4)Value(E)――对算术表达式E求值。
(5)CompoundExpr(p,E1,E2)――构造一个新的复合表达式(E1)p(E2)。
【二】【选做部分】
(1)以表达式的原书写形式输入,支持大于0的正整数常量;
(2)增加常数合并操作MergeConst(E)——合并表达式E中所有常数运算。例如,对表达式E=(2+3-a)*(b+3*4)进行合并常数的操作后,求得E=(5-a)*(b+12)
【测试数据】
1) 分别输入0;a -91 +a*bc +*5x2*8x +++*3^*2^x2x6并输出。
2) 每当输入一个表达式后,对其中的变量赋值,然后对表达式求值。
3) 还有很多测试的数据,详细请见附上的文件Test.txt。
-Between an expression and a binary tree, there is a natural correspondence. Write a program to realize the arithmetic expression based on Binary Tree for Expression of the operation.
Basic requirements of】 【
【1】 【will do some】
Suppose an arithmetic expression can contain variables in Expression (az), constant (0-9) and the binary operator (+,-,*,/,^( power)). To achieve the following:
(1) ReadExpr (E)- in the form of a sequence of characters enter the correct prefix expression syntax and constructs the expression E.
(2) WriteExpr (E)- with the infix expression with parentheses output expression E.
(3) Assign (V, c)- to achieve the assignment of the variable V (V = c), the variable s initial value is 0.
(4) Value (E)- E evaluation of arithmetic expressions.
(5) CompoundExpr (p, E1, E2)- construct a new complex expression (E1) p (E2).
【2】 【choose to do some】
(1) the original written form of expression input, support for constant positive integer greater than 0
(2) Platform: |
Size: 250880 |
Author:snake |
Hits:
Description: 则运算式求值,将四则运算式用中缀表达式表示,然后将它转变成后缀表达式,并且计算结果。
2、 基本要求:要求运用二叉树来实现。
-The expression is evaluated, the four expressions that use the infix expression, and then to transform it into a postfix expression, and results.
2, the basic requirements: Requires the use of binary tree to achieve. Platform: |
Size: 3072 |
Author:wuting |
Hits:
Description: 把一个写在文档中的中缀表达式以树的形式输出-To a written document in the form of an infix expression to the output tree Platform: |
Size: 922624 |
Author:张超 |
Hits:
Description: This code transforms an expression from infix form to prefix form (Polonese notation) and build the binary tree for the operation and the result of the calculation. Platform: |
Size: 59392 |
Author:Osemax |
Hits:
Description: implement a routine that takes an infix notation expression, converts it to postfix through an expression tree, and then evaluates the postfix notation. Platform: |
Size: 4096 |
Author:mike |
Hits:
Description: 一个表达式和一个二叉树之间,存在着自然的对应关系。写一个程序,实现基于二叉树的表示的算术表达式Expression的操作。
基本要求
1.ReadExpr(E) 以字符序列的形式输入语法正确的前缀表示式并够着表达式E。
2.WriteExpr(E) 用带括弧的中缀表达式输出表达式E。
3.Assign(V,c) 实现对变量V的赋值(V=c),变量的初值为0。
4.Value(E) 对算术表达式E求值。
5.CompoundExpr(P,E1,E2) 构造一个新的复合表达式(E1)P(E2)。
-Between an expression and a binary tree, there is a natural correspondence relationship. Write a program to achieve the operation of the binary tree-based representation of the arithmetic expression Expression. The basic requirements for input grammatically correct prefix expressions 1.ReadExpr (E) in the form of a sequence of characters and enough with the expression E. 2.WriteExpr (E) output expression E infix expression with parentheses. 3.Assign (V, c) the assignment of the variable V (V = c), the initial value of the variable to 0. 4.Value (E) E evaluates arithmetic expressions. 5.CompoundExpr (P, E1, E2) to construct a new composite expressions (E1) P (E2). Platform: |
Size: 6144 |
Author:wdtswdy |
Hits:
Description: CS2208 - Data Structures Lab (Anna University)
EXERCISES
1a. Implement singly linked lists.
1b. Implement doubly linked lists.
2. Represent a polynomial as a linked list and write functions for polynomial addition.
3. Implement stack and use it to convert infix to postfix expression
4. Implement a double-ended queue (dequeue) where insertion and deletion operations are possible at both the ends.
5. Implement an expression tree. Produce its pre-order, in-order, and postorder traversals.
6. Implement binary search tree.
7. Implement insertion in AVL trees.
8. Implement priority queue using binary heaps
9. Implement hashing with open addressing.
10. Implement Prim s algorithm using priority queues to find MST of an undirected graph. Platform: |
Size: 209920 |
Author:Narayana Swamy |
Hits:
Description: 数据结构树的演示程序,包括等价类合并、二叉树基本操作的实现、哈夫曼树、线索二叉树、前、中缀二叉树、表达式求值等程序。-
The tree data structure demo program, including the equivalence class combination, two tree basic operations to achieve Huffman tree, binary tree, two clues, and two binary tree, infix expression uation procedures.
Platform: |
Size: 671744 |
Author:wx |
Hits:
Description: 要求:构建一个表达式树,当输入中缀表达式时,输出并打印其前缀及后缀表达式
实现:构造一个标准的表达式树的类,它涵盖先序、中序、后序遍历操作,通过不同顺序的打印操作来实现转换操作;相对于使用栈来进行转换,免去了中缀转成前缀时进行的逆序操作(Requirements: to construct an expression tree, when the input infix expression, output and print the prefix and suffix expression
To achieve: constructing a standard expression tree, it covers the first order, in sequence, after the traversal operation, through the printing operation sequence to achieve the conversion operation; compared with the use of the stack to convert, eliminates the inverse operation of the infix turn into a prefix) Platform: |
Size: 2048 |
Author:舟齐
|
Hits: