Computer Science
Convert the following infix notation to postfix notation, showing stack and string contents at each step.
A * (( C + D)/E)
Python Stack
11 Likes
Answer
Given,
A * (( C + D)/E)
Scanning from left to right:
Symbol | Action | Stack | Postfix Expression |
---|---|---|---|
A | A | ||
* | Push | * | |
↑ | |||
( | Push | (* | |
↑ | |||
( | Push | ((* | |
↑ | |||
C | AC | ||
+ | Push | +((* | |
↑ | |||
D | ACD | ||
) | Pop till one opening bracket is popped and add popped operator to expression | (* | ACD+ |
↑ | |||
/ | Push | /(* | |
↑ | |||
E | ACD+E | ||
) | Pop till one opening bracket is popped and add popped operator to expression | * | ACD+E/ |
↑ | |||
End of expression | Pop all and add to expression | #Empty | ACD+E/* |
Postfix notation of A * (( C + D)/E) = ACD+E/*
Answered By
5 Likes
Related Questions
Evaluate following postfix expression while showing status of stack after each operation given A = 3, B = 5, C = 1, D = 4.
AB + C *
Evaluate following postfix expression while showing status of stack after each operation given A = 3, B = 5, C = 1, D = 4.
AB * C / D *
Convert the following infix notation to postfix notation, showing stack and string contents at each step.
A + B - C * D
Write a program to create a Stack for storing only odd numbers out of all the numbers entered by the user. Display the content of the Stack along with the largest odd number in the Stack. (Hint. Keep popping out the elements from stack and maintain the largest element retrieved so far in a variable. Repeat till Stack is empty)