SlideShare a Scribd company logo
Applications of STACK
Presented By:-
Yadraj Meena
K.V. INS KALINGA
 In computer science, a stack is an abstract data type
based on principle of(LIFO) that serves as a collection
of elements, with two principal operations: push,
which adds an element to the collection, and pop,
which removes the most recently added element.
 Functions necessary to implement a stack :
#include<iostream.h>
#define STACK_SIZE 20
int stack[STACK_SIZE]; /*space for stacking
integers*/
int top=-1; / *top_of_stack is
defined as global
variable for a global stack */
/*Function to check whether the stack is ‘full’ */
int stack_full()
{
if(top==STACK_SIZE-1)
return(1);
else
return(0);
}
 /* Function to check whether the stack is ‘empty’ */
int stack_empty()
{
if(top==-1)
return(1);
else
return(0);
}
/*Function to push or add an element on the stack.*/
void push(int number)
{
stack[++top]=number; /*add element on top of
stack */
}
 /* Function to pop an element from the stack*/
int pop()
{
int number;
number=stack[top]; /*remove top element from
stack */
top--;
return(number);
}
1. INFIX TO POSTFIX CONVERSION
2. EVALUATION OF POSTFIX EXPRESSION
 Infix notation is the common arithmetic and logical
formula notation, in which operators are written infix-
style between the operands they act on
 E.g. A + B
 In Postfix notation, the operator comes after the
Operand.
 For example, the Infix expression A+B will be written as
AB+ in its Postfix Notation.
 Postfix is also called ‘Reverse Polish Notation’
 In Prefix notation, the operator comes before the
operand.
 The Infix expression A+B will be written as +AB in its
Prefix Notation.
 Prefix is also called ‘Polish Notation’
ARITHMETIC OPERATORS Precedence
Exponentiation( ^ or ↑ ) HIGHEST
Multiplication and Division ( * , / ) MIDDLE
Addition and Subtraction ( + , - ) LOWEST
LOGICAL OPERATORS
NOT HIGHEST
AND MIDDLE
OR LOWEST
Algorithm: Infix to Postfix conversion
1. Enclose the expression in parentheses, that is, ( ).
2. Read next symbol of expression and repeat step 3 to 6 until
STACK is empty.
3. If the symbol is operand add to Postfix Expression
4.If the symbol read is ‘(‘ then push it into STACK.
5. If symbol read = operator then
(1) Repeat while ( Precedence of TOP(STACK)
>= precedence of
operator read)
{ POP operator from STACK and add operator to PE}
(2) Push operator into STACK
6. If the symbol read is ‘)’ then
(1) Repeat while( TOP[Stack] != ‘(‘ )
{ POP operator from stack and add to PE}
(2) Remove the ‘(‘ . [ it must not be added to PE ]
7. PE is the desired equivalent Postfix Expression
8. End
( A B+ (* -C /)D )E
(
A ( A
+ (+ A
B (+ AB
* (+* AB
( (+*( AB
C (+*( ABC
- (+*(- ABC
D (+*(- ABCD
) (+* ABCD-
/ (+/ ABCD-*
E (+/ ABCD-*E
) ABCD-*E/+
Scanned Element STACK OUTPUT(PE)
(
OUTPUT : ABCD-*E/+
 Convert infix to Postfix:
 ( A * B + ( C – D / E ))
( A * +B C( D- F/ ) )
Scanned Element STACK OUTPUT(PE)
( (
A ( A
* (* A
B (* AB
+ (+ AB*
( (+( AB*
C (+( AB*C
- (+(- AB*C
D (+(- AB*CD
/ (+(-/ AB*CD
F (+(-/ AB*CDF
) (+ AB*CDF/-
) AB+CDF/-+
OUTPUT : AB+CDF/-+
 Algorithm Steps
1. Create an empty stack STACK
2. Read next symbol of the Postfix expression PE and repeat
steps 3 and 4 until end of the expression is reached.
3. If(symbol read = operand) then PUSH(STACK , Symbol read)
4. If(symbol read = operator) then
{ if(operator = unary operator)
{ POP(Stack, symbol)
Evaluate the expression so formed and PUSH
the result onto STACK }
else
{ POP(STACK, symbol1)
POP(STACK, symbol 2)
Evaluate result = symbol2 operator symbol1
PUSH(STACK, result) }
}
5. POP(STACK, result)
6. End
Evaluate: 50 , 60 , + , 20 , 10 , - , *
OUTPUT : 1100
Scanned
Element
Operation Stack
Status
50 Push 50
60 Push 50, 60
+ Pop twice, 50 + 60 = 110
Push result
110
20 Push 110, 20
10 Push 110,20,10
- Pop twice, 20 – 10 =10
Push result
110,10
* Pop twice, 110 * 10 = 1100
Push result
1100
Evaluate the expression:
 True, False, NOT, AND ,False ,True ,OR ,
AND
Evaluate: True, False, NOT, AND ,False ,True ,OR , AND
OUTPUT: True
Scanned
Element
Operation Stack Status
True Push True
False Push True, False
NOT Pop one element and apply NOT operation
And Push the result into stack
True, True
AND True
False Push True, False
True Push True, False
True
OR True, True
AND True
Pop one element and apply AND operation
And Push the result into stack
Pop one element and apply OR operation
And Push the result into stack
Pop one element and apply AND operation
And Push the result into stack
THANKS…..
YOU

More Related Content

What's hot

Stack Operation In Data Structure
Stack Operation In Data Structure Stack Operation In Data Structure
Stack Operation In Data Structure
DivyeshKumar Jagatiya
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
Praveen Vishwakarma
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
Soumen Santra
 
Stacks
StacksStacks
Stacks
sweta dargad
 
Stack application
Stack applicationStack application
Stack application
Student
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack
StackStack
stack
stackstack
stack
Raj Sarode
 
Polish
PolishPolish
Polish
joie rocker
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
Mandeep Singh
 
stack presentation
stack presentationstack presentation
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
Sheikh Monirul Hasan
 
Stack Data Structure V1.0
Stack Data Structure V1.0Stack Data Structure V1.0
Stack Data Structure V1.0
Zidny Nafan
 
Stack
StackStack
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
Bhavesh Sanghvi
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
Soumen Santra
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
EktaVaswani2
 

What's hot (19)

Stack Operation In Data Structure
Stack Operation In Data Structure Stack Operation In Data Structure
Stack Operation In Data Structure
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
 
Stacks
StacksStacks
Stacks
 
Stack application
Stack applicationStack application
Stack application
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack
StackStack
Stack
 
stack
stackstack
stack
 
Polish
PolishPolish
Polish
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
stack presentation
stack presentationstack presentation
stack presentation
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 
Stack Data Structure V1.0
Stack Data Structure V1.0Stack Data Structure V1.0
Stack Data Structure V1.0
 
Stack
StackStack
Stack
 
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 

Viewers also liked

Vtecx20151216 2
Vtecx20151216 2Vtecx20151216 2
Vtecx20151216 2
Shinichiro Takezaki
 
2010SanteAwardsWinnersPressReleasel
2010SanteAwardsWinnersPressReleasel2010SanteAwardsWinnersPressReleasel
2010SanteAwardsWinnersPressReleaselHeidi Hinkle
 
Enhancing Relevancy & User Experience with #SharePoint Search sps-philly 2015
Enhancing Relevancy & User Experience with #SharePoint Search   sps-philly 2015Enhancing Relevancy & User Experience with #SharePoint Search   sps-philly 2015
Enhancing Relevancy & User Experience with #SharePoint Search sps-philly 2015
Gina Montgomery, V-TSP
 
Arial9
Arial9Arial9
Arial9
08070807
 
Aramara
AramaraAramara
Aramara
Aramara96
 
Vtecx20151216
Vtecx20151216Vtecx20151216
Vtecx20151216
Shinichiro Takezaki
 
01
0101
01
dd
 
Cyber crime
Cyber crimeCyber crime
Cyber crime
Nirali Shah
 
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
Gina Montgomery, V-TSP
 
Vtecxlt20151201
Vtecxlt20151201Vtecxlt20151201
Vtecxlt20151201
Shinichiro Takezaki
 
SPSNYC - Next Generation Portals
SPSNYC - Next Generation PortalsSPSNYC - Next Generation Portals
SPSNYC - Next Generation Portals
Bob German
 
Observacion de una clase
Observacion de una claseObservacion de una clase
Observacion de una clase
Aramara96
 
Lead magnets: getting more prospects on your email list
Lead magnets: getting more prospects on your email listLead magnets: getting more prospects on your email list
Lead magnets: getting more prospects on your email list
Rodolfo Melogli
 
ACMで作成するSSL証明書の活用
ACMで作成するSSL証明書の活用ACMで作成するSSL証明書の活用
ACMで作成するSSL証明書の活用
Ikuna Wada
 
The power of social proof
The power of social proofThe power of social proof
The power of social proof
Rodolfo Melogli
 
Informe de observación en la escuela primaria
Informe de observación en la escuela primariaInforme de observación en la escuela primaria
Informe de observación en la escuela primariaMaria Vega
 

Viewers also liked (18)

Vtecx20151216 2
Vtecx20151216 2Vtecx20151216 2
Vtecx20151216 2
 
2010SanteAwardsWinnersPressReleasel
2010SanteAwardsWinnersPressReleasel2010SanteAwardsWinnersPressReleasel
2010SanteAwardsWinnersPressReleasel
 
Enhancing Relevancy & User Experience with #SharePoint Search sps-philly 2015
Enhancing Relevancy & User Experience with #SharePoint Search   sps-philly 2015Enhancing Relevancy & User Experience with #SharePoint Search   sps-philly 2015
Enhancing Relevancy & User Experience with #SharePoint Search sps-philly 2015
 
Arial9
Arial9Arial9
Arial9
 
Aramara
AramaraAramara
Aramara
 
Vtecx20151216
Vtecx20151216Vtecx20151216
Vtecx20151216
 
Spm Pics
Spm PicsSpm Pics
Spm Pics
 
01
0101
01
 
CWTS
CWTSCWTS
CWTS
 
Cyber crime
Cyber crimeCyber crime
Cyber crime
 
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
Enhancing Relevancy & User Experience with SharePoint Search - SPSBMORE 2015
 
Vtecxlt20151201
Vtecxlt20151201Vtecxlt20151201
Vtecxlt20151201
 
SPSNYC - Next Generation Portals
SPSNYC - Next Generation PortalsSPSNYC - Next Generation Portals
SPSNYC - Next Generation Portals
 
Observacion de una clase
Observacion de una claseObservacion de una clase
Observacion de una clase
 
Lead magnets: getting more prospects on your email list
Lead magnets: getting more prospects on your email listLead magnets: getting more prospects on your email list
Lead magnets: getting more prospects on your email list
 
ACMで作成するSSL証明書の活用
ACMで作成するSSL証明書の活用ACMで作成するSSL証明書の活用
ACMで作成するSSL証明書の活用
 
The power of social proof
The power of social proofThe power of social proof
The power of social proof
 
Informe de observación en la escuela primaria
Informe de observación en la escuela primariaInforme de observación en la escuela primaria
Informe de observación en la escuela primaria
 

Similar to Applicationofstack by Ali F.RAshid

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
Unit 3 stack
Unit 3   stackUnit 3   stack
Unit 3 stack
kalyanineve
 
The concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdfThe concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdf
arihantsherwani
 
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 and its applications
Stack and its applicationsStack and its applications
Stack and its applications
Ahsan Mansiv
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
pinakspatel
 
Stack
StackStack
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
AliRaza899305
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
Omprakash Chauhan
 
Stack
StackStack
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
Stack Applications
Stack ApplicationsStack Applications
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
partho5958
 
stack-Intro.pptx
stack-Intro.pptxstack-Intro.pptx
stack-Intro.pptx
DEEPAK948083
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
chandankumar364348
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
kumarkaushal17
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)
mailmerk
 

Similar to Applicationofstack by Ali F.RAshid (20)

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
Unit 3 stack
Unit 3   stackUnit 3   stack
Unit 3 stack
 
The concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdfThe concept of stack is extremely important in computer science and .pdf
The concept of stack is extremely important in computer science and .pdf
 
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
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
 
Stack
StackStack
Stack
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
 
Stack
StackStack
Stack
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
 
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
16-StacksQueuesCVCJUCGTCXYFRSTTIUGIUFTY.ppt
 
stack-Intro.pptx
stack-Intro.pptxstack-Intro.pptx
stack-Intro.pptx
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptx
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)
 

Recently uploaded

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

Applicationofstack by Ali F.RAshid

  • 1. Applications of STACK Presented By:- Yadraj Meena K.V. INS KALINGA
  • 2.  In computer science, a stack is an abstract data type based on principle of(LIFO) that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element.
  • 3.  Functions necessary to implement a stack : #include<iostream.h> #define STACK_SIZE 20 int stack[STACK_SIZE]; /*space for stacking integers*/ int top=-1; / *top_of_stack is defined as global variable for a global stack */ /*Function to check whether the stack is ‘full’ */ int stack_full() { if(top==STACK_SIZE-1) return(1); else return(0); }
  • 4.  /* Function to check whether the stack is ‘empty’ */ int stack_empty() { if(top==-1) return(1); else return(0); } /*Function to push or add an element on the stack.*/ void push(int number) { stack[++top]=number; /*add element on top of stack */ }
  • 5.  /* Function to pop an element from the stack*/ int pop() { int number; number=stack[top]; /*remove top element from stack */ top--; return(number); }
  • 6. 1. INFIX TO POSTFIX CONVERSION 2. EVALUATION OF POSTFIX EXPRESSION
  • 7.  Infix notation is the common arithmetic and logical formula notation, in which operators are written infix- style between the operands they act on  E.g. A + B
  • 8.  In Postfix notation, the operator comes after the Operand.  For example, the Infix expression A+B will be written as AB+ in its Postfix Notation.  Postfix is also called ‘Reverse Polish Notation’
  • 9.  In Prefix notation, the operator comes before the operand.  The Infix expression A+B will be written as +AB in its Prefix Notation.  Prefix is also called ‘Polish Notation’
  • 10. ARITHMETIC OPERATORS Precedence Exponentiation( ^ or ↑ ) HIGHEST Multiplication and Division ( * , / ) MIDDLE Addition and Subtraction ( + , - ) LOWEST LOGICAL OPERATORS NOT HIGHEST AND MIDDLE OR LOWEST
  • 11. Algorithm: Infix to Postfix conversion 1. Enclose the expression in parentheses, that is, ( ). 2. Read next symbol of expression and repeat step 3 to 6 until STACK is empty. 3. If the symbol is operand add to Postfix Expression 4.If the symbol read is ‘(‘ then push it into STACK. 5. If symbol read = operator then (1) Repeat while ( Precedence of TOP(STACK) >= precedence of operator read) { POP operator from STACK and add operator to PE} (2) Push operator into STACK 6. If the symbol read is ‘)’ then (1) Repeat while( TOP[Stack] != ‘(‘ ) { POP operator from stack and add to PE} (2) Remove the ‘(‘ . [ it must not be added to PE ] 7. PE is the desired equivalent Postfix Expression 8. End
  • 12. ( A B+ (* -C /)D )E ( A ( A + (+ A B (+ AB * (+* AB ( (+*( AB C (+*( ABC - (+*(- ABC D (+*(- ABCD ) (+* ABCD- / (+/ ABCD-* E (+/ ABCD-*E ) ABCD-*E/+ Scanned Element STACK OUTPUT(PE) ( OUTPUT : ABCD-*E/+
  • 13.  Convert infix to Postfix:  ( A * B + ( C – D / E ))
  • 14. ( A * +B C( D- F/ ) ) Scanned Element STACK OUTPUT(PE) ( ( A ( A * (* A B (* AB + (+ AB* ( (+( AB* C (+( AB*C - (+(- AB*C D (+(- AB*CD / (+(-/ AB*CD F (+(-/ AB*CDF ) (+ AB*CDF/- ) AB+CDF/-+ OUTPUT : AB+CDF/-+
  • 15.  Algorithm Steps 1. Create an empty stack STACK 2. Read next symbol of the Postfix expression PE and repeat steps 3 and 4 until end of the expression is reached. 3. If(symbol read = operand) then PUSH(STACK , Symbol read) 4. If(symbol read = operator) then { if(operator = unary operator) { POP(Stack, symbol) Evaluate the expression so formed and PUSH the result onto STACK } else { POP(STACK, symbol1) POP(STACK, symbol 2) Evaluate result = symbol2 operator symbol1 PUSH(STACK, result) } } 5. POP(STACK, result) 6. End
  • 16. Evaluate: 50 , 60 , + , 20 , 10 , - , * OUTPUT : 1100 Scanned Element Operation Stack Status 50 Push 50 60 Push 50, 60 + Pop twice, 50 + 60 = 110 Push result 110 20 Push 110, 20 10 Push 110,20,10 - Pop twice, 20 – 10 =10 Push result 110,10 * Pop twice, 110 * 10 = 1100 Push result 1100
  • 17. Evaluate the expression:  True, False, NOT, AND ,False ,True ,OR , AND
  • 18. Evaluate: True, False, NOT, AND ,False ,True ,OR , AND OUTPUT: True Scanned Element Operation Stack Status True Push True False Push True, False NOT Pop one element and apply NOT operation And Push the result into stack True, True AND True False Push True, False True Push True, False True OR True, True AND True Pop one element and apply AND operation And Push the result into stack Pop one element and apply OR operation And Push the result into stack Pop one element and apply AND operation And Push the result into stack