Algorithm and Flowchart for Postfix to Infix Notation

[9188 views]




Infix notation is a type of notation in which arithmetic expressions are written in a manner such that the operators appear in between the operands.

Algorithm for Postfix to Infix Notation

Postfix notation is a type of notation in which arithmetic expressions are written in a manner such that the operands appear before their operators.

Let' see how to convert Postfix expression to Infix expression:

Flowchart for Postfix to Infix Conversion:

Flowchart for Postfix to Infix Conversion
Remove WaterMark from Above Flowchart

Algorithm for Postfix to Infix Conversion:

Step 1: Start Step 2: Read the Postfix expression from left to right. Step 3: If the scanned character is an operand, then push it onto the Stack. Step 4: If the scanned character is an operator, pop two operands from the stack and concatenate them in order of 'operand1,operator, operand2'. Push the result into the stack. Step 5: Repeat steps 2-4 until the postfix expression ends. Step 6: Pop all the rest elements of the stack if any. Step 7: Stop

Let's take an example to understand cb+a*

  1. Reading from left to right, we scan the operands 'c' 'b' respectively and push it into the the stack.
  2. '+' is scanned and operands 'c', 'b' are popped and concatenated in form of c+b
  3. 'a' is then pushed into the stack.
  4. '*', is encountered and 'a' and string 'c+b' is popped and concatenated to give a string (c+b)*a
  5. Postfix form is obtained: (c+b)*a

You might be interested in this too.:

                 



Want to Learn How to write own Algorithm and Flowcharts



Want to test your logical skills in Algorithms?




Comments










Search Anything:

Sponsored Deals ends in





Technical Quizzes Specially For You:

Search Tags

    Pseudocode for Postfix to Infix

    Postfix to infix conversion easy algorithm