Professional Documents
Culture Documents
GTU # 3130702
Unit-2
Linear Data
Structure Stack
a+b*c+d*e
1 2
3
4
1. [Initialize Stack]
TOP 1
S[TOP] ← ‘(’
2. [Initialize output string and rank
count]
POLISH ‘’
RANK 0
3. [Get first input symbol]
NEXT NEXTCHAR(INFIX)
Empty
Read – , is it
Stack Read 5, is it operator? POP two
operand? PUSH
Read 6, is it 2 symbols and
perform operation
operand? PUSH
Read 2, is it 6 and PUSH result 4
operand? PUSH 5 Operan – Operan 5
d1 d2
Read + , is it
Read next operator? POP two
symbol, if it is symbols and perform
end of string, operation and PUSH
POP answer result
Answ 9
er
from Stack Operan
d1
+ Operan
d2
Thank
You