SlideShare a Scribd company logo
Conversion of Infix to Prefix and
Postfix with Stack
Infix Notation
To add A, B, we write
A+B
To multiply A, B, we write
A*B
The operators ('+' ,'*‘ and many more)
go in between the operands ('A' and 'B')
This is "Infix" notation.
Prefix Notation
Instead of saying "A plus B", we could
say "add A,B " and write
+ A B
"Multiply A,B" would be written
* A B
The operators ('+' ,'*‘ and many more) go
in front of the operands ('A' and 'B')
This is “Prefix” notation.
Postfix Notation
Another alternative is to put the
operators after the operands as in
“AB +” and “AB *”
The operators ('+' ,’*‘ and many more) go
in end of the operands ('A' and 'B')
This is “Postfix“ notation.
Priority/Precedence of Arithmetic
Operators:-
Highest Precedence  ( ) , î or ^.
Mid Precedence  * , / .
Lowest Precedence  + , - .
Conversion of Infix to Postfix with stack
 A+B*C
Symbol Stack Postfix
A Empty A
+ + A
B + AB
* +* AB
C +* ABC
+ ABC*
Empty ABC*+
 (A+B)*C
Symbol Stack Postfix
( ( Empty
A ( A
+ (+ A
B (+ AB
) Empty AB+
* * AB+
C * AB+C
AB+C*
Conversion of Infix to Prefix with stack
 (A*B+C)=(C+B*A)
Symbol Stack Postfix
( ( Empty
C ( C
+ (+ C
B (+ CB
* (+* CB
A (+* CBA
) (+*) CBA*+
Prefix=+*ABC
 (A/B^C+D) = (D+C^B/A)
Symbol Stack Postfix
( ( Empty
D ( D
+ (+ D
C (+ DC
^ (+^ DC
B (+^ DCB
/ (+/ DCB^
A (+/ DCB^A
) (+/) DCB^A/+
Prefix:- +/A^BCD
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
Ad

More Related Content

What's hot (20)

Stack
StackStack
Stack
Seema Sharma
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Stack
StackStack
Stack
Zaid Shabbir
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
Digvijay Singh Karakoti
 
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
Bhavesh Sanghvi
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Infix prefix postfix
Infix prefix postfixInfix prefix postfix
Infix prefix postfix
Self-Employed
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
Sayantan Sur
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
JeeSa Sultana
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Queues
QueuesQueues
Queues
Ashim Lamichhane
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Linked List
Linked ListLinked List
Linked List
Ashim Lamichhane
 
Linked list
Linked listLinked list
Linked list
akshat360
 
Breadth First Search & Depth First Search
Breadth First Search & Depth First SearchBreadth First Search & Depth First Search
Breadth First Search & Depth First Search
Kevin Jadiya
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Stacks
StacksStacks
Stacks
Malainine Zaid
 
Stack application
Stack applicationStack application
Stack application
Student
 

Similar to Conversion of Infix to Prefix and Postfix with Stack (17)

Prefix and PostFIx presentation for DSA .pptx
Prefix and PostFIx presentation for DSA .pptxPrefix and PostFIx presentation for DSA .pptx
Prefix and PostFIx presentation for DSA .pptx
rtiwary190801
 
Problem solving with algorithm and data structure
Problem solving with algorithm and data structureProblem solving with algorithm and data structure
Problem solving with algorithm and data structure
Rabia Tariq
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
Ain-ul-Moiz Khawaja
 
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
devismileyrockz
 
EXPRESSIONS.pptx
EXPRESSIONS.pptxEXPRESSIONS.pptx
EXPRESSIONS.pptx
Sachin013
 
Data structures
Data structures Data structures
Data structures
Rokonuzzaman Rony
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
ecomputernotes
 
Lecture6
Lecture6Lecture6
Lecture6
Muhammad Zubair
 
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
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
Meghaj Mallick
 
Stack
StackStack
Stack
Maleeha Khawar Hashmie
 
DS1.pptx
DS1.pptxDS1.pptx
DS1.pptx
Momin24
 
infixtopostfixconversion-110304220159-phpapp01.pptx
infixtopostfixconversion-110304220159-phpapp01.pptxinfixtopostfixconversion-110304220159-phpapp01.pptx
infixtopostfixconversion-110304220159-phpapp01.pptx
shesnasuneer
 
Lecture_04.2.pptx
Lecture_04.2.pptxLecture_04.2.pptx
Lecture_04.2.pptx
RockyIslam5
 
Stack application in infix to prefix expression
Stack application in infix to prefix expressionStack application in infix to prefix expression
Stack application in infix to prefix expression
deepalishinkar1
 
data structure stack appplication in python
data structure stack appplication in pythondata structure stack appplication in python
data structure stack appplication in python
deepalishinkar1
 
Stack Data Structure Intro and Explanation
Stack Data Structure Intro and ExplanationStack Data Structure Intro and Explanation
Stack Data Structure Intro and Explanation
RitikaLohiya2
 
Prefix and PostFIx presentation for DSA .pptx
Prefix and PostFIx presentation for DSA .pptxPrefix and PostFIx presentation for DSA .pptx
Prefix and PostFIx presentation for DSA .pptx
rtiwary190801
 
Problem solving with algorithm and data structure
Problem solving with algorithm and data structureProblem solving with algorithm and data structure
Problem solving with algorithm and data structure
Rabia Tariq
 
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
devismileyrockz
 
EXPRESSIONS.pptx
EXPRESSIONS.pptxEXPRESSIONS.pptx
EXPRESSIONS.pptx
Sachin013
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
ecomputernotes
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
Meghaj Mallick
 
DS1.pptx
DS1.pptxDS1.pptx
DS1.pptx
Momin24
 
infixtopostfixconversion-110304220159-phpapp01.pptx
infixtopostfixconversion-110304220159-phpapp01.pptxinfixtopostfixconversion-110304220159-phpapp01.pptx
infixtopostfixconversion-110304220159-phpapp01.pptx
shesnasuneer
 
Lecture_04.2.pptx
Lecture_04.2.pptxLecture_04.2.pptx
Lecture_04.2.pptx
RockyIslam5
 
Stack application in infix to prefix expression
Stack application in infix to prefix expressionStack application in infix to prefix expression
Stack application in infix to prefix expression
deepalishinkar1
 
data structure stack appplication in python
data structure stack appplication in pythondata structure stack appplication in python
data structure stack appplication in python
deepalishinkar1
 
Stack Data Structure Intro and Explanation
Stack Data Structure Intro and ExplanationStack Data Structure Intro and Explanation
Stack Data Structure Intro and Explanation
RitikaLohiya2
 
Ad

Recently uploaded (20)

Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Anti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptxAnti-Depressants pharmacology 1slide.pptx
Anti-Depressants pharmacology 1slide.pptx
Mayuri Chavan
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Unit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdfUnit 6_Introduction_Phishing_Password Cracking.pdf
Unit 6_Introduction_Phishing_Password Cracking.pdf
KanchanPatil34
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Ad

Conversion of Infix to Prefix and Postfix with Stack

  • 1. Conversion of Infix to Prefix and Postfix with Stack
  • 2. Infix Notation To add A, B, we write A+B To multiply A, B, we write A*B The operators ('+' ,'*‘ and many more) go in between the operands ('A' and 'B') This is "Infix" notation.
  • 3. Prefix Notation Instead of saying "A plus B", we could say "add A,B " and write + A B "Multiply A,B" would be written * A B The operators ('+' ,'*‘ and many more) go in front of the operands ('A' and 'B') This is “Prefix” notation.
  • 4. Postfix Notation Another alternative is to put the operators after the operands as in “AB +” and “AB *” The operators ('+' ,’*‘ and many more) go in end of the operands ('A' and 'B') This is “Postfix“ notation.
  • 5. Priority/Precedence of Arithmetic Operators:- Highest Precedence  ( ) , î or ^. Mid Precedence  * , / . Lowest Precedence  + , - .
  • 6. Conversion of Infix to Postfix with stack  A+B*C Symbol Stack Postfix A Empty A + + A B + AB * +* AB C +* ABC + ABC* Empty ABC*+
  • 7.  (A+B)*C Symbol Stack Postfix ( ( Empty A ( A + (+ A B (+ AB ) Empty AB+ * * AB+ C * AB+C AB+C*
  • 8. Conversion of Infix to Prefix with stack  (A*B+C)=(C+B*A) Symbol Stack Postfix ( ( Empty C ( C + (+ C B (+ CB * (+* CB A (+* CBA ) (+*) CBA*+ Prefix=+*ABC
  • 9.  (A/B^C+D) = (D+C^B/A) Symbol Stack Postfix ( ( Empty D ( D + (+ D C (+ DC ^ (+^ DC B (+^ DCB / (+/ DCB^ A (+/ DCB^A ) (+/) DCB^A/+ Prefix:- +/A^BCD