- #1
zak100
- 462
- 11
Homework Statement
I am trying to convert following from infix to post fix:
(4+8)*(6-5)/((3-2)*(2+2))
I am facing problem at character 20 which is a ‘(‘ i.e. opening bracket.
Homework Equations
There is no eq but the algorihm is given below:
I got following algorithm from internet.
1. if (t is an operand) output t.
2. else if (t is a right parentheses){ POP and output tokens until a left parentheses is popped(but do not output) }
3. else { POP and output tokens until one of lower priority than t is encountered or a left parentheses is encountered. or the stack is empty. PUSH t. }
The Attempt at a Solution
I am facing problem at character 20 which is a ‘(‘ i.e. opening bracket. At character 19 i.e. at '*' i.e. (asterisk) I have following status:
Character = *
Stack = /(*
Output = 4 8 + 6 5 - * 3 2 –
At character 20 i.e. ( , as per above algorithm, I would come to step 3. so I am popping tokens & I have following status after character 20:
Character = (
Stack = /((
Output = 4 8 + 6 5 - * 3 2 – *
But the above is wrong. Some body please guide me what is my mistake?Zulfi.
Last edited by a moderator: