Question

Given the expression, (x+y)*w+u/(v+x*w)+z, Please show the content in the stack after the operand vis read...

Given the expression, (x+y)*w+u/(v+x*w)+z, Please show the content in the stack after the operand vis read in postfix transformation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have made a table which involves the operations and the following are the things which need to take into consideration while reading the table.

  1. the stack column contains the stack at each operation and left is the bottom-most element and right is the topmost element of the stack.
  2. Operation column contains the description of the operation performed upon reading the new character which can be read from the character column.
  3. Postfix is the string which is generated until now.

Following is the table.

Sno Character Post-fix stack(bottom…..top) operation
1 ( ( Put the bracket opening to the stack
2 x x ( append the character to postfix
3 + x (+ add to the stack
4 y xy (+ append the character to postfix
5 ) xy+ - pop out of the stack until first (
6 * xy+ * push to the stack
7 w xy+w * append the character to postfix
8 + xy+w* + Popped out until the operations having greater precedence than +
9 u xy+w*u + append the character to postfix
10 / xy+w*u +/ push to the stack
11 ( xy+w*u +/( push to the stack
12 v xy+w*uv +/( append the character to postfix
13 + xy+w*uv +/(+ push to the stack
14 x xy+w*uvx +/(+ append the character to postfix
15 * xy+w*uvx +/(+* push to the stack
16 w xy+w*uvxw +/(+* append the character to postfix
17 ) xy+w*uvxw*+ +/ Pop until the (
18 + xy+w*uvxw*+/+ + Popped out until the operations having greater precedence than +
19 z xy+w*uvxw*+/+z + append the character to postfix
20 xy+w*uvxw*+/+z+ - popped the remaining operations

That was a nice question to answer
Friend, If you have any doubts in understanding do let me know in the comment section. I will be happy to help you further.
Please like if you think effort deserves a like.
Thanks

Add a comment
Know the answer?
Add Answer to:
Given the expression, (x+y)*w+u/(v+x*w)+z, Please show the content in the stack after the operand vis read...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT