ITP

BCA - OOPS and Data Structures

Algoritham to convert Infix to Postfix expression

In : BCA Subject : OOPS and Data Structures

STEP 1 : Read the given infix expression into string called infix.

STEP 2 : Read one character at a time and perform the following operations :
1. If the read character is an operand, then add the operand to the postfix string.
2. If the read character is not an operand, then check
        If the stack is not empty and precedence of the top of the 
           stack operator is higher than the read operator,
        then pop the operator from stack and add this 
               operator to the postfix string. 
        Else push the operator onto the stack.

STEP 3 : Repeat STEP 2 till all characters are processed from the input string.

STEP 4 : If stack is not empty, then pop the operator from stack and add this operator to the postfix string.

STEP 5 : Repeat STEP 4 till all the operators are popped from the stack.

STEP 6 : Display the result of given infix expression or resultant postfix expression stored in a string called postfix from this algorithm.

About us

A truly open platform where you may ask questions and get answers. We also provide comprehensive and easy-to-understand answers to question papers.  discover...

Site status

Flag Counter

Privacy Policy

Sitemap