SlideShare a Scribd company logo
Infix to Postfix
Dr. Yashoda M B
1. Scan the infix expression from left to right.
2. If the scanned character is an operand, put it in the postfix expression.
3. Otherwise, do the following
• If the precedence of the current scanned operator is higher than the precedence of
the operator on top of the stack, or if the stack is empty, or if the stack contains a ‘(‘,
then push the current operator onto the stack.
• Else, pop all operators from the stack that have precedence higher than or equal to
that of the current operator. After that push the current operator onto the stack.
4. If the scanned character is a ‘(‘, push it to the stack.
5. If the scanned character is a ‘)’, pop the stack and output it until a ‘(‘ is
encountered, and discard both the parenthesis.
6. Repeat steps 2-5 until the infix expression is scanned.
7. Once the scanning is over, Pop the stack and add the operators in the
postfix expression until it is not empty.
8. Finally, print the postfix expression.
• Consider the infix expression exp = “a+b*c+d”
and the infix expression is scanned using the iterator i, which is
initialized as i = 0.
• 1st Step: Here i = 0 and exp[i] = ‘a’ i.e., an operand. So add this in the
postfix expression. Therefore, postfix = “a”.
• 2nd Step: Here i = 1 and exp[i] = ‘+’ i.e., an operator. Push this into the
stack. postfix = “a” and stack = {+}.
• 3rd Step: Now i = 2 and exp[i] = ‘b’ i.e., an operand. So add this in the
postfix expression. postfix = “ab” and stack = {+}.
• 4th Step: Now i = 3 and exp[i] = ‘*’ i.e., an operator. Push this into the
stack. postfix = “ab” and stack = {+, *}.
• 5th Step: Now i = 4 and exp[i] = ‘c’ i.e., an operand. Add this in the
postfix expression. postfix = “abc” and stack = {+, *}.
• 6th Step: Now i = 5 and exp[i] = ‘+’ i.e., an operator. The topmost
element of the stack has higher precedence. So pop until the stack
becomes empty or the top element has less precedence. ‘*’ is popped
and added in postfix. So postfix = “abc*” and stack = {+}.
• Now top element is ‘+‘ that also doesn’t have less precedence. Pop it.
postfix = “abc*+”.
• Now stack is empty. So push ‘+’ in the stack. stack = {+}.
• 7th Step: Now i = 6 and exp[i] = ‘d’ i.e., an operand. Add this in the
postfix expression. postfix = “abc*+d”.
• Final Step: Now no element is left. So empty the stack and add it in
the postfix expression. postfix = “abc*+d+”.

More Related Content

Similar to conversion of Infix to Postfix conversion using stack (20)

Data strutcure and annalysis topic stack
Data strutcure and annalysis topic stackData strutcure and annalysis topic stack
Data strutcure and annalysis topic stack
MihirMishra36
 
Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)
lahariit406
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
Usha P
 
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptxData Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
RashidFaridChishti
 
Stack
StackStack
Stack
Tejas Patel
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
Then Murugeshwari
 
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.pptStack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
aamirali1061a
 
Stack
StackStack
Stack
Zaid Shabbir
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Stack
StackStack
Stack
Maleeha Khawar Hashmie
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
stack-111104232459-phpapp02.pdf
stack-111104232459-phpapp02.pdfstack-111104232459-phpapp02.pdf
stack-111104232459-phpapp02.pdf
Kalpana Mohan
 
Data structure_Stack Introduction & app.
Data structure_Stack Introduction & app.Data structure_Stack Introduction & app.
Data structure_Stack Introduction & app.
AnuradhaJadiya1
 
Stack application
Stack applicationStack application
Stack application
Ravi solanki
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
GADAPURAMSAINIKHIL
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
Ain-ul-Moiz Khawaja
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix2.2 stack applications Infix to Postfix & Evaluation of Post Fix
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
Applicationofstack by Ali F.RAshid
Applicationofstack  by Ali F.RAshid Applicationofstack  by Ali F.RAshid
Applicationofstack by Ali F.RAshid
ali rashid
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj Meena
Dipayan Sarkar
 
Data strutcure and annalysis topic stack
Data strutcure and annalysis topic stackData strutcure and annalysis topic stack
Data strutcure and annalysis topic stack
MihirMishra36
 
Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)
lahariit406
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
Usha P
 
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptxData Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
RashidFaridChishti
 
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.pptStack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
aamirali1061a
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
stack-111104232459-phpapp02.pdf
stack-111104232459-phpapp02.pdfstack-111104232459-phpapp02.pdf
stack-111104232459-phpapp02.pdf
Kalpana Mohan
 
Data structure_Stack Introduction & app.
Data structure_Stack Introduction & app.Data structure_Stack Introduction & app.
Data structure_Stack Introduction & app.
AnuradhaJadiya1
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
GADAPURAMSAINIKHIL
 
Prefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix NotationsPrefix, Infix and Post-fix Notations
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
Applicationofstack by Ali F.RAshid
Applicationofstack  by Ali F.RAshid Applicationofstack  by Ali F.RAshid
Applicationofstack by Ali F.RAshid
ali rashid
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj Meena
Dipayan Sarkar
 

More from yashodamb (10)

Introduction to Cloud computing concept.pptx
Introduction to Cloud computing concept.pptxIntroduction to Cloud computing concept.pptx
Introduction to Cloud computing concept.pptx
yashodamb
 
Introduction to Database Management System.pptx
Introduction to Database Management System.pptxIntroduction to Database Management System.pptx
Introduction to Database Management System.pptx
yashodamb
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
yashodamb
 
Cascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examplesCascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examples
yashodamb
 
applets.pptx
applets.pptxapplets.pptx
applets.pptx
yashodamb
 
Navigation between the worksheets.pptx
Navigation between the worksheets.pptxNavigation between the worksheets.pptx
Navigation between the worksheets.pptx
yashodamb
 
Implementing a Java Program.pptx
Implementing a Java Program.pptxImplementing a Java Program.pptx
Implementing a Java Program.pptx
yashodamb
 
Thread life cycle.pptx
Thread life cycle.pptxThread life cycle.pptx
Thread life cycle.pptx
yashodamb
 
DECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptxDECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptx
yashodamb
 
History of C programming.pptx
History of C programming.pptxHistory of C programming.pptx
History of C programming.pptx
yashodamb
 
Introduction to Cloud computing concept.pptx
Introduction to Cloud computing concept.pptxIntroduction to Cloud computing concept.pptx
Introduction to Cloud computing concept.pptx
yashodamb
 
Introduction to Database Management System.pptx
Introduction to Database Management System.pptxIntroduction to Database Management System.pptx
Introduction to Database Management System.pptx
yashodamb
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
yashodamb
 
Cascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examplesCascading style sheet: complete explanation with some examples
Cascading style sheet: complete explanation with some examples
yashodamb
 
applets.pptx
applets.pptxapplets.pptx
applets.pptx
yashodamb
 
Navigation between the worksheets.pptx
Navigation between the worksheets.pptxNavigation between the worksheets.pptx
Navigation between the worksheets.pptx
yashodamb
 
Implementing a Java Program.pptx
Implementing a Java Program.pptxImplementing a Java Program.pptx
Implementing a Java Program.pptx
yashodamb
 
Thread life cycle.pptx
Thread life cycle.pptxThread life cycle.pptx
Thread life cycle.pptx
yashodamb
 
DECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptxDECISION MAKING STATEMENTS.pptx
DECISION MAKING STATEMENTS.pptx
yashodamb
 
History of C programming.pptx
History of C programming.pptxHistory of C programming.pptx
History of C programming.pptx
yashodamb
 

Recently uploaded (20)

TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
Module I. Democracy, Elections & Good Governance
Module I. Democracy, Elections & Good GovernanceModule I. Democracy, Elections & Good Governance
Module I. Democracy, Elections & Good Governance
srkmcop0027
 
Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)
NileshKumbhar21
 
Salinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plantSalinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plant
aliabatool11
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18
Celine George
 
Regression Analysis-Machine Learning -Different Types
Regression Analysis-Machine Learning -Different TypesRegression Analysis-Machine Learning -Different Types
Regression Analysis-Machine Learning -Different Types
Global Academy of Technology
 
The Board Doesn’t Care About Your Roadmap: Running Product at the Board
The Board Doesn’t Care About Your Roadmap: Running Product at the BoardThe Board Doesn’t Care About Your Roadmap: Running Product at the Board
The Board Doesn’t Care About Your Roadmap: Running Product at the Board
victoriamangiantini1
 
NA FASE REGIONAL DO TL – 1.º CICLO. .
NA FASE REGIONAL DO TL – 1.º CICLO.     .NA FASE REGIONAL DO TL – 1.º CICLO.     .
NA FASE REGIONAL DO TL – 1.º CICLO. .
Colégio Santa Teresinha
 
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdfLeveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
TechSoup
 
How to create Record rules in odoo 18 - Odoo Slides
How to create Record rules in odoo 18 - Odoo  SlidesHow to create Record rules in odoo 18 - Odoo  Slides
How to create Record rules in odoo 18 - Odoo Slides
Celine George
 
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptxALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
Sourav Kr Podder
 
NS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptxNS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptx
manuelaromero2013
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Amit Kumar Sahoo
 
The Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptxThe Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptx
Arshad Shaikh
 
Online elections for Parliament for European Union
Online elections for Parliament for European UnionOnline elections for Parliament for European Union
Online elections for Parliament for European Union
Monica Enache
 
From Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI StrategyFrom Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI Strategy
victoriamangiantini1
 
Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025
Mebane Rash
 
Decision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression TreeDecision Tree-ID3,C4.5,CART,Regression Tree
Decision Tree-ID3,C4.5,CART,Regression Tree
Global Academy of Technology
 
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup - Microsoft Discontinuation of Selected Cloud Donated Offers 2025.05...
TechSoup
 
Module I. Democracy, Elections & Good Governance
Module I. Democracy, Elections & Good GovernanceModule I. Democracy, Elections & Good Governance
Module I. Democracy, Elections & Good Governance
srkmcop0027
 
Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)Combustion in Compression Ignition Engine (CIE)
Combustion in Compression Ignition Engine (CIE)
NileshKumbhar21
 
Salinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plantSalinity Resistance in Plants.Rice plant
Salinity Resistance in Plants.Rice plant
aliabatool11
 
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf5503 Course Proposal Online Computer Middle School Course Wood M.pdf
5503 Course Proposal Online Computer Middle School Course Wood M.pdf
Melanie Wood
 
Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18Automated Actions (Automation) in the Odoo 18
Automated Actions (Automation) in the Odoo 18
Celine George
 
Regression Analysis-Machine Learning -Different Types
Regression Analysis-Machine Learning -Different TypesRegression Analysis-Machine Learning -Different Types
Regression Analysis-Machine Learning -Different Types
Global Academy of Technology
 
The Board Doesn’t Care About Your Roadmap: Running Product at the Board
The Board Doesn’t Care About Your Roadmap: Running Product at the BoardThe Board Doesn’t Care About Your Roadmap: Running Product at the Board
The Board Doesn’t Care About Your Roadmap: Running Product at the Board
victoriamangiantini1
 
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdfLeveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
Leveraging AI to Streamline Operations for Nonprofits [05.20.2025].pdf
TechSoup
 
How to create Record rules in odoo 18 - Odoo Slides
How to create Record rules in odoo 18 - Odoo  SlidesHow to create Record rules in odoo 18 - Odoo  Slides
How to create Record rules in odoo 18 - Odoo Slides
Celine George
 
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptxALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
ALL BENGAL U25 QUIZ LEAGUE 2.0 SET BY SKP.pptx
Sourav Kr Podder
 
NS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptxNS3 Unit 5 Energy presentation 2025.pptx
NS3 Unit 5 Energy presentation 2025.pptx
manuelaromero2013
 
he Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Successhe Grant Preparation Playbook: Building a System for Grant Success
he Grant Preparation Playbook: Building a System for Grant Success
TechSoup
 
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Quality Assurance and Quality Management, B. Pharm 6th Semester-Unit-1
Amit Kumar Sahoo
 
The Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptxThe Reproductive System of Insects: An Overview.pptx
The Reproductive System of Insects: An Overview.pptx
Arshad Shaikh
 
Online elections for Parliament for European Union
Online elections for Parliament for European UnionOnline elections for Parliament for European Union
Online elections for Parliament for European Union
Monica Enache
 
From Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI StrategyFrom Hype to Moat: Building a Defensible AI Strategy
From Hype to Moat: Building a Defensible AI Strategy
victoriamangiantini1
 
Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025Statement by Linda McMahon on May 21, 2025
Statement by Linda McMahon on May 21, 2025
Mebane Rash
 

conversion of Infix to Postfix conversion using stack

  • 1. Infix to Postfix Dr. Yashoda M B
  • 2. 1. Scan the infix expression from left to right. 2. If the scanned character is an operand, put it in the postfix expression. 3. Otherwise, do the following • If the precedence of the current scanned operator is higher than the precedence of the operator on top of the stack, or if the stack is empty, or if the stack contains a ‘(‘, then push the current operator onto the stack. • Else, pop all operators from the stack that have precedence higher than or equal to that of the current operator. After that push the current operator onto the stack. 4. If the scanned character is a ‘(‘, push it to the stack. 5. If the scanned character is a ‘)’, pop the stack and output it until a ‘(‘ is encountered, and discard both the parenthesis. 6. Repeat steps 2-5 until the infix expression is scanned. 7. Once the scanning is over, Pop the stack and add the operators in the postfix expression until it is not empty. 8. Finally, print the postfix expression.
  • 3. • Consider the infix expression exp = “a+b*c+d” and the infix expression is scanned using the iterator i, which is initialized as i = 0. • 1st Step: Here i = 0 and exp[i] = ‘a’ i.e., an operand. So add this in the postfix expression. Therefore, postfix = “a”.
  • 4. • 2nd Step: Here i = 1 and exp[i] = ‘+’ i.e., an operator. Push this into the stack. postfix = “a” and stack = {+}.
  • 5. • 3rd Step: Now i = 2 and exp[i] = ‘b’ i.e., an operand. So add this in the postfix expression. postfix = “ab” and stack = {+}.
  • 6. • 4th Step: Now i = 3 and exp[i] = ‘*’ i.e., an operator. Push this into the stack. postfix = “ab” and stack = {+, *}.
  • 7. • 5th Step: Now i = 4 and exp[i] = ‘c’ i.e., an operand. Add this in the postfix expression. postfix = “abc” and stack = {+, *}.
  • 8. • 6th Step: Now i = 5 and exp[i] = ‘+’ i.e., an operator. The topmost element of the stack has higher precedence. So pop until the stack becomes empty or the top element has less precedence. ‘*’ is popped and added in postfix. So postfix = “abc*” and stack = {+}.
  • 9. • Now top element is ‘+‘ that also doesn’t have less precedence. Pop it. postfix = “abc*+”.
  • 10. • Now stack is empty. So push ‘+’ in the stack. stack = {+}.
  • 11. • 7th Step: Now i = 6 and exp[i] = ‘d’ i.e., an operand. Add this in the postfix expression. postfix = “abc*+d”.
  • 12. • Final Step: Now no element is left. So empty the stack and add it in the postfix expression. postfix = “abc*+d+”.