__Problem 1:__

Give postfix form of the following expression

- A*(B+(C+D)*(E+F)/G)*H
- A+((B+C)*(D+E)*F)/G
- A*(B+D)/E-F-(G+H/K)
- ((A-B)*(D/E))/(F*G*H)

__Problem 2:__

Evaluate the following postfix expression using a stack and show the contents of stack after each step

- 50 40 +18 14-4*+
- 100 40 8+20 10 -+*
- 5 6 9 +80 5*-/
- 120 45+20 10-15+*
- 20 45+20 10-15+*

__Problem 3:__

Simplify the following infix expressions using operator precedence rules

- 8-2*3-1
- 12/(6-2)
- (4+3)*(8-5)

__Solution:__

(1) A=8-2*3-1

* has higher precedence than -. so 2*3 is executed first

A=8-6-1.both are -.so evaluate from left to right

A=2-1=1

**A=1**

(2)B=12/(6-2)

operation in parentheses are done first.so 6-2=4

B=12/4=3

**B=3**

(3)C=(4+3)*(8-5)

operation in parentheses done first

C=7*(8-5)

C=7*3

**C=21**

__Problem 4__Are the following two infix expressions equivalent?

- A+B*C
- (A+B)*C

__Solution:__

The two infix expressions are different.The multiplication is performed first in the first expression while the addition is performed first in the second expression.

I think the Answer at this file

ReplyDeletehttp://www.mediafire.com/?z6k9g56iwr3332b

ReplyDeletesolutions to the problems 1 and 2....

ReplyDelete