Answer:1. [Initialize Stack]
top <-- 1
s[top] <-- ‘#’.
2. [Initialize output string and rank count]
POLISH <-- ‘ ‘
RANK <-- 0.
3. [Get first input string]
NEXT <-- call NEXTCHAR(INFIX).
4. [Translate infix expression]
Repeat thru step 6 while NEXT != ‘#’.
5. [Remove symbols with greater or equal precedence from stack]
Repeat while
F(NEXT <= F (s[top])
X <-- call pop(s , top)
POLISH <-- POLISH O X
RANK <-- RANK +call R(X)
If ( RANK < 1)
then write (Invalid Expression”)
exit.
6. [Pushing current element to stack]
call push (s , top , NEXT)
NEXT <-- call NEXTCHAR(INFIX).
7. [Moving remaining stack elements to polish]
Repeat while s[top] != ‘#’
X <-- call pop(s , top)
POLISH <-- POLISH O X
RANK <-- RANK + call R(X)
If ( RANK < 1)
then write (Invalid Expression”)
exit.
8. [Checking validity of total expression]
If (RANK != 1)
then write (Invalid Expression”).
9. [FINISH]
return.