CISC 235 Lecture Notes - Lecture 8: Reverse Polish Notation, Polish Notation, Binary Tree

56 views8 pages

Document Summary

When an operator is encountered in the left-to-right order, we apply it to the two values that immediately precede it then put the result into the expression to replace the operator and its operands. 3 4 + 8 * 5 2 - * is evaluated (showing all the stages) as. The notation that most of us have grown up with is formally called infix notation: operators are placed between their operands, and we use parentheses and precedence rules to control the order of evaluation. The expression above, in infix notation, would be (3 + 4) * 8 * (5 - 2) We need the parentheses because if we just wrote. 3 + 4 * 8 * 5 - 2 our standard precedence rules would give a different result. This illustrates the idea that postfix notation is shorter than infix (no parenthesis) and easier to evaluate (it"s just left-to-right).

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