Infix To Prefix Convertion
ALGORITHM:
STEP 1:
Add " ( " at the beginning of the infix expression and then reverse.
STEP 2:
Push " ) " on to the stack.
STEP 3:
Scan every character and repeat step 4 to step 7 until " ( " is encountered.
STEP 4:
If input is operand add in the output.
STEP 5:
If input is " ) " push into the stack.
STEP 6:
If input is "(" pop all the operators from the stack and add in the output one by one until ")" is popped.
STEP 7:
If input is operator pop all the stack which is higher precedence than input operator .Push input operator into the stack.
STEP 8:
Reverse the output
EndFragment