0% found this document useful (0 votes)
176 views

5 - Infix To Postfix Conversion Using Stack

Uploaded by

Boyina Viswanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views

5 - Infix To Postfix Conversion Using Stack

Uploaded by

Boyina Viswanth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Data Structures & Algorithms

Unit -3
Infix to Postfix Conversion Using Stack

Pankaj Chandra
Assistant Professor
IT GGV
Infix to Postfix conversion Using Stack
To convert Infix Expression into Postfix Expression using a stack
data structure, We can use the following steps –

1. Read all the symbols one by one from left to right in the given
Infix Expression.

2. If the reading symbol is operand, then directly print it to the


result (Output).

3. If the reading symbol is left parenthesis '(', then Push it on to the


Stack.
Infix to Postfix conversion Using Stack
4. If the reading symbol is right parenthesis ')', then Pop
all the contents of stack until respective left parenthesis
is poped and print each poped symbol to the result.

5. If the reading symbol is operator (+ , - , * , / etc.,), then


Push it on to the Stack. However, first pop the operators
which are already on the stack that have higher or equal
precedence than current operator and print them to the
result.
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Infix to Postfix conversion Using Stack
Consider the following Infix Expression...
(A+B)*(C-D)
Thank You

You might also like