SlideShare une entreprise Scribd logo
1  sur  19
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

Contenu connexe

Tendances

Stack & Queue using Linked List in Data Structure
Stack & Queue using Linked List in Data StructureStack & Queue using Linked List in Data Structure
Stack & Queue using Linked List in Data StructureMeghaj Mallick
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Queue implementation
Queue implementationQueue implementation
Queue implementationRajendran
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applicationsSaqib Saeed
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked ListReazul Islam
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackSoumen Santra
 
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 ADTSoumen Santra
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - NotesOmprakash Chauhan
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stacksahil kumar
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.pptTirthika Bandi
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queuesBuxoo Abdullah
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure Janki Shah
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTUREMandeep Singh
 

Tendances (20)

Stack & Queue using Linked List in Data Structure
Stack & Queue using Linked List in Data StructureStack & Queue using Linked List in Data Structure
Stack & Queue using Linked List in Data Structure
 
Stack
StackStack
Stack
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
stack presentation
stack presentationstack presentation
stack presentation
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Infix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using StackInfix to Postfix Conversion Using Stack
Infix to Postfix Conversion Using Stack
 
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
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Conversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with StackConversion of Infix to Prefix and Postfix with Stack
Conversion of Infix to Prefix and Postfix with Stack
 
Linklist
LinklistLinklist
Linklist
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Ppt presentation of queues
Ppt presentation of queuesPpt presentation of queues
Ppt presentation of queues
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 

En vedette

CloudConnect 2012: The cloud application stack
CloudConnect 2012: The cloud application stackCloudConnect 2012: The cloud application stack
CloudConnect 2012: The cloud application stackGeva Perry
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleHitesh Kumar
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked ListSayantan Sur
 
Stack implementation using c
Stack implementation using cStack implementation using c
Stack implementation using cRajendran
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 

En vedette (9)

Extendible hashing
Extendible hashingExtendible hashing
Extendible hashing
 
CloudConnect 2012: The cloud application stack
CloudConnect 2012: The cloud application stackCloudConnect 2012: The cloud application stack
CloudConnect 2012: The cloud application stack
 
Chapter13
Chapter13Chapter13
Chapter13
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of Example
 
Stack using Linked List
Stack using Linked ListStack using Linked List
Stack using Linked List
 
Computer ethics
Computer ethicsComputer ethics
Computer ethics
 
Seminar algorithms of web
Seminar algorithms of webSeminar algorithms of web
Seminar algorithms of web
 
Stack implementation using c
Stack implementation using cStack implementation using c
Stack implementation using c
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 

Similaire à Application of Stack - Yadraj Meena

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
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 .pdfarihantsherwani
 
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) .pptxhaaamin01
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applicationsAhsan Mansiv
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacksmaamir farooq
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-listpinakspatel
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - NotesOmprakash Chauhan
 
Stack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxStack_Overview_Implementation_WithVode.pptx
Stack_Overview_Implementation_WithVode.pptxchandankumar364348
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)mailmerk
 

Similaire à Application of Stack - Yadraj Meena (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
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
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
 
Stack Operation In Data Structure
Stack Operation In Data Structure Stack Operation In Data Structure
Stack Operation In Data Structure
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
 
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)
 

Plus de Dipayan Sarkar

introduction to aep arc
introduction to aep arcintroduction to aep arc
introduction to aep arcDipayan Sarkar
 
why focus on adolescents unique needs
why focus on adolescents unique needswhy focus on adolescents unique needs
why focus on adolescents unique needsDipayan Sarkar
 
aep in india milestones, learning, way forward
aep in india milestones, learning, way forwardaep in india milestones, learning, way forward
aep in india milestones, learning, way forwardDipayan Sarkar
 
Softskills - S Fernandez
Softskills - S FernandezSoftskills - S Fernandez
Softskills - S FernandezDipayan Sarkar
 
Project Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaProject Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaDipayan Sarkar
 
Linux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarLinux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarDipayan Sarkar
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K UpadhyayDipayan Sarkar
 
Sorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishSorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishDipayan Sarkar
 
Information Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakInformation Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakDipayan Sarkar
 
Universal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliUniversal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliDipayan Sarkar
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin RamolaDipayan Sarkar
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDipayan Sarkar
 
Java Databse Connectvity- Alex Jose
Java Databse Connectvity- Alex JoseJava Databse Connectvity- Alex Jose
Java Databse Connectvity- Alex JoseDipayan Sarkar
 
Computer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyComputer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyDipayan Sarkar
 
Cloud Computing- Sreehari S
Cloud Computing- Sreehari SCloud Computing- Sreehari S
Cloud Computing- Sreehari SDipayan Sarkar
 

Plus de Dipayan Sarkar (18)

Relationships
RelationshipsRelationships
Relationships
 
ideal learning space
ideal learning spaceideal learning space
ideal learning space
 
introduction to aep arc
introduction to aep arcintroduction to aep arc
introduction to aep arc
 
why focus on adolescents unique needs
why focus on adolescents unique needswhy focus on adolescents unique needs
why focus on adolescents unique needs
 
aep in india milestones, learning, way forward
aep in india milestones, learning, way forwardaep in india milestones, learning, way forward
aep in india milestones, learning, way forward
 
Softskills - S Fernandez
Softskills - S FernandezSoftskills - S Fernandez
Softskills - S Fernandez
 
Project Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K ChaurdiaProject Based Learning- Ashish K Chaurdia
Project Based Learning- Ashish K Chaurdia
 
Linux and the Open Source- D Sarkar
Linux and the Open Source- D SarkarLinux and the Open Source- D Sarkar
Linux and the Open Source- D Sarkar
 
File Handling - N K Upadhyay
File Handling - N K UpadhyayFile Handling - N K Upadhyay
File Handling - N K Upadhyay
 
Sorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan SatishSorting Techniques - Govardhan Satish
Sorting Techniques - Govardhan Satish
 
Information Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K PathakInformation Technology Act 2000 - Santosh K Pathak
Information Technology Act 2000 - Santosh K Pathak
 
Universal Gates - Aneesa N Ali
Universal Gates - Aneesa N AliUniversal Gates - Aneesa N Ali
Universal Gates - Aneesa N Ali
 
Selection Sort - Vipin Ramola
Selection Sort - Vipin RamolaSelection Sort - Vipin Ramola
Selection Sort - Vipin Ramola
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K Karun
 
Java Databse Connectvity- Alex Jose
Java Databse Connectvity- Alex JoseJava Databse Connectvity- Alex Jose
Java Databse Connectvity- Alex Jose
 
Computer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan ChakravarthyComputer Viruses- B S Kalyan Chakravarthy
Computer Viruses- B S Kalyan Chakravarthy
 
Cloud Computing- Sreehari S
Cloud Computing- Sreehari SCloud Computing- Sreehari S
Cloud Computing- Sreehari S
 
SQL JOINS- Reena P V
SQL JOINS- Reena P VSQL JOINS- Reena P V
SQL JOINS- Reena P V
 

Dernier

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 

Dernier (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

Application of Stack - Yadraj Meena

  • 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