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 string s */ S = CreateStack(N); /* S is stack of operators */ r= malloc(N + 1); j = 0; for ( each character c in s ) { if (c is operand){ r[j++] = c; continue; } if (IsEmpty()) { _(1). continue; } p = Top(S); pc = incoming precedence of c; pp = in-stack precedence of p; if ( _(2)) { Push(c, S); continue; } while (3)){ _{ r[j++] = p; _(4); if (IsEmpty(S)) break; p = Top(S); pp = in-stack precedence of p; } if (pc == pp) { (5)___; continue; } Push(c, S); } _ ) { while ( _(6) _(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
