CSE 214 Lecture Notes - Lecture 1: Reverse Polish Notation, Infix Notation, Operand

129 views4 pages

Document Summary

The operands precede the operator (@ means + - * or /) 3 4 + = 3+4= 7: in the expression, replace @ and its operands with the computed value, repeat 1-3 the process until no more operators exist. Here is the sequence of operations: 2 3 4 * , 2 12 + 3 4*is replaced by 12 , the value of 3*4. + is next operator, perform 2 12+ replace 2 12+ with 14. Another example, 3 4 * 2 5 * + which in infix notation is 3*4 + 2*5. * is the first operator 3 4 * is replaced by 12. 1: when you are finished scanning the expression, the final value remains on the stack. Pop 4, pop 3, do 3 *4 , push 12. Pop 12, pop 2, do 2 + 12, push 14. Here is an algorithm to evaluate postfix expressions. To eliminate some unnecessary and non-instructive details make a few simplifying assumptions:

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents