Reverse Polish Notation Flashcards

1
Q

what notation is RPN

A

postfix

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

give two advantages of RPN

A
  • no brackets to show correct order of calculation
  • no backtracking when evaluating
  • quicker for computers to evaluate
  • no need for order of presedence
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

give an example of the difference between postfix and infix

A
  • postfix: 43+
  • infix: 4+3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

describe the reverse polish pseudocode

A
  • while tokens in RPN
  • if next token is a value then add to stack
  • else get operator, pop item off the stack and place to the right
  • pop item of stack and place to the left
  • place brackets around new expression and push it onto stack
  • pop expression
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

convert the following infix to postfix

3 + 11

A

311+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

convert the following infix to postfix

3 / (5+y*x)

A

35yx*+/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how would the infix expression 3 + 4 * 2 - 1 be represented in RPN

A

34+2*1-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly