







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








Algorithm to Convert Infix to Postfix Q is the Expression in infix P is the output in postfix Initialization:
Algorithm to Evaluate a Postfix Expression stk = the empty stack /* scan the input string reading one element / / at a time into symb / while (not end of input) { symb = next input character; if (symb is an operand) push(stk, symb) else { / symb is an operator / opnd1 = pop(stk); opnd2 = pop(stk); value = opnd2 OPERATOR opnd1; push(stk, value); } / end else / } / end while */ return (pop(stk)); Example: Postfix Expression: 6 2 3 + - 3 8 2 / + * 2 ^ 3 + symb opnd1 (^) opnd2 value stk 6 6 2 6, 3 6,2,