Question: Assignment Stacks Part I Evaluate the postfix expressions. Use the algorithm to Evaluate postfix expression (page - 373). You MUST show the steps as in

Assignment Stacks

Part I Evaluate the postfix expressions. Use the algorithm to Evaluate postfix expression (page - 373). You MUST show the steps as in Figure 7.13 (Page 374) . < 5 >

Assume a = 7, b = 8, c = 3, and d = -1

Postfix expression: a b c d - / *

Step #

Expression

Stack status

Operation

1

7 8 3 -1 - / *

2

8 3 -1 - / *

3

3 -1 - / *

4

-1 - / *

5

- / *

6

/ *

7

*

End (Value of the expression)

Final Result = ______

Part II Convert the infix expression to postfix expression. Use the algorithm to convert infix expression to postfix expression (page - 378). You MUST show the steps as in Figure 7.14 (Page 379) . < 5 >

Infix expression: (a - b) * w - (x * y / z)

Step #

Expression

Stack

Postfix Expression

1

(a - b) * w - (x * y / z)

2

a - b) * w - (x * y / z)

3

- b) * w - (x * y / z)

4

b) * w - (x * y / z)

5

) * w - (x * y / z)

6

* w - (x * y / z)

7

w - (x * y / z)

8

- (x * y / z)

9

(x * y / z)

10

x * y / z)

11

* y / z)

12

y / z)

13

/ z)

14

z)

15

)

End (RPN Expression)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!