Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started