Question: The algorithm of infix to postfix conversion is given below. An expression is represented by a string, an operand is represented by a letter (for

The algorithm of infix to postfix conversion is given below. An expression is represented by a string, an operand is represented by a letter (for example, "a+b*c-d"). Fill blanks in the algorithm. convert infix expressions to postfix expression r char *Infix ToPostfix(char *s) { N = strlen(s); /" length of strings S = CreateStack(); /* S is stack of operators */ r=malloc(N+1); j = 0; for each character cins) { if (c is operand r[j++] = c; continue; } if (IsEmpty()) { (1)_ continue 1 p = Top(S); pc = incoming precedence of c; pp = in-stack precedence of p; if _(2) Pushic, S): continue ) { } while (3) _(4) Pop(S): if (IsEmpty(S)) break; p = Top(S); pp = in-stack precedence of p; } if _(5) Pop(S); continue } Push(c, S): } while (6) K _(7) Pop(S); } DisposeStack( Stack S); free(r); return r; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
