55. Reverse Polish notation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

convert the following reverse polish notation expression to its equivalent infix expression:
4 6 +

A

4 + 6

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

convert the following reverse polish notation expression to its equivalent infix expression:
8 2 -

A

8 -2

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

convert the following reverse polish notation expression to its equivalent infix expression:
4 9 + 6 x

A

(4 + 9) x 6

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

convert the following reverse polish notation expression to its equivalent infix expression:
10 4 7 + x

A

10 x (4 + 7)

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

convert the following reverse polish notation expression to its equivalent infix expression:
3 9 + 4 2 - x

A

(3 + 9) x (4 - 2)

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

convert the following infix notation expression to its equivalent reverse polish notation expression:
4 + 3

A

4 3 +

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

convert the following infix notation expression to its equivalent reverse polish notation expression:
56 - 40

A

56 40 -

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
convert the following infix notation expression to its equivalent reverse polish notation expression:
5 x (5 - 3)
A

5 5 3 - x

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

convert the following infix notation expression to its equivalent reverse polish notation expression:
(6 / 3) + (6 + 2)

A

6 3 / 6 2 + +

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

convert the following infix notation expression to its equivalent reverse polish notation expression:
(18 - 8) x (30 + 20)

A

18 8 - 30 20 + x

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

why do we use reverse polish notation?

A

it eliminates the need for brackets in sub-expressions
it produces expressions in a form suitable for evaluation using a stack
it is used in interpreters based on stack; for example, postscript and bytecode
operands and operators need to be in correct sequence for computer to execute

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

what do we refer to regular way we write arithmetic expressions as?

A

infix notation

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

another name for reverse polish notation?

A

postfix notation

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

what is the first step in translating from infix to reverse polish notation?

A

define the order of precedence of operators

e.g. = ( + - ) * / ^ ~

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

describe the evaluation of reverse polish notation using a stack

A

once a compiler has translated and arithmetic expression into RPN, each symbol in the expression may be held in a string or array
the expression may then be evaluated using a stack scanning the elements of the string (or array) from left to right
- if the next token is an operand, place it on the stack
- if the next token is an operator, remove the required number of the operands from the stack, perform the operation, and put the result on the stack

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

when using a in-order traversal of a binary expression tree to represent expressions, what corresponding format will the algebraic expression be in?

A

Infix

17
Q

when using a post-order traversal of a binary expression tree to represent expressions, what corresponding format will the algebraic expression be in?

A

Postfix