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. Anexpression is represented by a string, an operand is represented by aletter (for example, "a+b*c-d). Fill blanks in the algorithm. /* convert infix

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!