Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void infixToPostfix ( char * infix, char * postfix ) { int i , j; int top = - 1 ; char stack [ Max

void infixToPostfix(char* infix, char* postfix){ int i, j; int top =-1; char stack[Max_Length]; for (i =0, j =0; infix[i]!='\0'; i++){ if (isOperand(infix[i])){ postfix[j++]= infix[i]; } else if (infix[i]=='('){ stack[++top]= infix[i]; } else if (infix[i]==')'){ while (top !=-1 && stack[top]!='('){ postfix[j++]= stack[top--]; } top--; // Pop '(' from the stack } else { while (top !=-1 && precedence(infix[i])<= precedence(stack[top])){ postfix[j++]= stack[top--]; } stack[++top]= infix[i]; }} while (top !=-1){ postfix[j++]= stack[top--]; } postfix[j]='\0';} Is this code correct

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions