SlideShare a Scribd company logo
1 of 31
INTRODUCTION
 What is Stack?
 Stack Representation
 ADT specification of Stack
 Operations on Stack
 Stack Overflow and Stack Underflow
 Implementing of Stack
 Prefix, Postfix, Infix Notation
 Polish Notation
 Precedence and Priority
 Applications
WHAT IS STACK??
 Stores a set of elements in a particular order.
 Stack is like a container of memory.
 Stack principle- LAST IN FIRST OUT(LIFO)
Examples:-
LAST IN FIRST OUT
STACK REPRESENTATION
ADT SPCIFICATIONS OF STACK
Operations:
 Make Empty
 Boolean Is Empty
 Boolean Is Full
 Push (Item Type new Item)
 Pop (Item Type& item) (or pop and top)
TOP
 A list with the restriction that insertion and deletion
can be performed only from one end is called top.
 If stack is empty, then top is at -1 position.
 If stack is not empty, then top is at last position(n-1).
PUSH OPERATION
 Stack is empty, top is at -1 position.
 Function: Adds new Item to the top of the stack.
 Preconditions: Stack has been initialized and is not full.
 Post conditions: new Item is at the top of the stack.
PSEUDO CODE IN C
Void push() {
int item;
printf(“Enter item to push”);
scanf(“%d”.&item);
if(top == max – 1) { // overflow condition
printf(“Stack overflow”);
}
else {
top = top + 1;
stack[top] = item;
}
}
PUSH OPERATION
POP OPERATION
 Stack is not empty, then top is at last position (n-1).
 Removes top Item from stack and returns it in item.
 Always done on the top of stack
 The top most element is deleted first
 Preconditions: Stack has been initialized and is not
empty.
 Post conditions: Top element has been removed from
stack and item is a copy of the removed element.
PSEUDO CODE IN C
Void pop () {
if(top == -1)
printf(“Stack underflow”);
else {
printf(“The deleted item is %d”,stack[top]);
top--;
}
}
POP OPERATION
STACK OVERFLOW
 The condition resulting from trying to push an element
onto a full stack.
 Top is at last position(n-1).
STACK UNDERFLOW
 The condition resulting from trying to pop an
empty stack.
 Top is at -1 position.
IMPLEMENTING OF STACK
Basics two choices:-
 Array
 Linked list
1) Array:-
Array is quick, but limited in size.
IMPLEMENTING OF STACK
2) Linked list:-
Linked List requires overhead to allocate, link,
unlink, and deallocate, but is not limited in size
INFIX EXPRESSION
 Operator is used in between operands.
 Example:-
POSTFIX EXPRESSION
 Operator is used after operands.
 Example:-
PREFIX EXPRESSION
 Operator is used before operands.
 Example:-
POLISH NOTATION
 Prefix notation requires that all operators precede the two
operands that they work on.
 Postfix notation requires that its operators come after the
corresponding operands.
PRECEDENCE AND PRIORITY
INFIX TO POSTFIX
 The infix string from left to right.
 Initialize an empty stack.
 Character is an operand, add it to the Postfix
string.
 If the stack is empty, push the character is an
operator to stack
 stack is not empty, compare the precedence of
the character with the element on top of the
stack.
EXAMPLE OF INFIX TO
POSTFIX
INFIX TO PREFIX
 Reverse given prefix expression.
 Conversion same as infix to postfix expression.
 Reverse the expression.
EXAMPLE OF INFIX TO
PREFIX
EVALUATION OF POSTFIX
 Create a stack to store operands (or values).
 If the element is a number, push it into the stack.
 If the element is a operator, pop operands for the operator
from stack.
 Evaluate the operator and push the result back to the stack
when the expression is ended, the number in the stack is
the final answer.
EXAMPLE OF EVALUATION
OF POSTFIX
EVALUATION OF PREFIX
 Accept a prefix string from the user.
 The string from the right one character at a time.
 If it is an operand, push it in stack.
 If it is an operator, pop and perform the operation,
specified by the operator.
 Push the result in the stack.
 The number in stack is final answer.
EXAMPLE OF
EVALUATION OF PREFIX
APPLICATIONS
 Parsing
 Recursive Function
 Calling Function
 Expression Evaluation
 Expression Conversion
 Infix to Postfix
 Infix to Prefix
 Postfix to Infix
 Prefix to Infix
Stack Data Structure: Implementation, Operations, Applications

More Related Content

What's hot (20)

Stacks
StacksStacks
Stacks
 
Hashing In Data Structure
Hashing In Data Structure Hashing In Data Structure
Hashing In Data Structure
 
Stack
StackStack
Stack
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 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
 
Queues
QueuesQueues
Queues
 
Heaps
HeapsHeaps
Heaps
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Stack
StackStack
Stack
 
Shell sort
Shell sortShell sort
Shell sort
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Applications of queues ii
Applications of queues   iiApplications of queues   ii
Applications of queues ii
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Stack using Array
Stack using ArrayStack using Array
Stack using Array
 
linked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutoriallinked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutorial
 
stack presentation
stack presentationstack presentation
stack presentation
 

Similar to Stack Data Structure: Implementation, Operations, Applications

Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxSLekshmiNair
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureYaksh Jethva
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptxrupam100
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data StructureUshaP15
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptxSonaPathak4
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9sumitbardhan
 
Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
Concept of stack ,stack of aaray stack by linked list , application of stac...
Concept of stack ,stack of aaray   stack by linked list , application of stac...Concept of stack ,stack of aaray   stack by linked list , application of stac...
Concept of stack ,stack of aaray stack by linked list , application of stac...muskankumari7360
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptxline24arts
 
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxStack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxShivam Kumar
 

Similar to Stack Data Structure: Implementation, Operations, Applications (20)

Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptx
 
Team 3
Team 3Team 3
Team 3
 
5.-Stacks.pptx
5.-Stacks.pptx5.-Stacks.pptx
5.-Stacks.pptx
 
CH4.pptx
CH4.pptxCH4.pptx
CH4.pptx
 
DS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptxDS UNIT1_STACKS.pptx
DS UNIT1_STACKS.pptx
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9
 
Chapter 6 ds
Chapter 6 dsChapter 6 ds
Chapter 6 ds
 
Lecture5
Lecture5Lecture5
Lecture5
 
Stack organization
Stack organizationStack organization
Stack organization
 
Concept of stack ,stack of aaray stack by linked list , application of stac...
Concept of stack ,stack of aaray   stack by linked list , application of stac...Concept of stack ,stack of aaray   stack by linked list , application of stac...
Concept of stack ,stack of aaray stack by linked list , application of stac...
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxStack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptx
 

More from Devyani Chaudhari

PASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDPASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDDevyani Chaudhari
 
Troubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsTroubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsDevyani Chaudhari
 
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGINTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGDevyani Chaudhari
 

More from Devyani Chaudhari (6)

Online Education.pptx
Online Education.pptxOnline Education.pptx
Online Education.pptx
 
SQL
SQLSQL
SQL
 
PASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORDPASSWORD SECURITY BASED ON HONEYWORD
PASSWORD SECURITY BASED ON HONEYWORD
 
Troubleshooting methods of computer peripherals
Troubleshooting methods of computer peripheralsTroubleshooting methods of computer peripherals
Troubleshooting methods of computer peripherals
 
Elastic Block Storage (EBS)
Elastic Block Storage (EBS)Elastic Block Storage (EBS)
Elastic Block Storage (EBS)
 
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCINGINTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
INTRODUCTION TO ARDUINO & RASPBERRY, SENSOR AND TEMPERATURE INTERAFCING
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

Stack Data Structure: Implementation, Operations, Applications

  • 1. INTRODUCTION  What is Stack?  Stack Representation  ADT specification of Stack  Operations on Stack  Stack Overflow and Stack Underflow  Implementing of Stack  Prefix, Postfix, Infix Notation  Polish Notation  Precedence and Priority  Applications
  • 2. WHAT IS STACK??  Stores a set of elements in a particular order.  Stack is like a container of memory.  Stack principle- LAST IN FIRST OUT(LIFO) Examples:-
  • 5. ADT SPCIFICATIONS OF STACK Operations:  Make Empty  Boolean Is Empty  Boolean Is Full  Push (Item Type new Item)  Pop (Item Type& item) (or pop and top)
  • 6. TOP  A list with the restriction that insertion and deletion can be performed only from one end is called top.  If stack is empty, then top is at -1 position.  If stack is not empty, then top is at last position(n-1).
  • 7. PUSH OPERATION  Stack is empty, top is at -1 position.  Function: Adds new Item to the top of the stack.  Preconditions: Stack has been initialized and is not full.  Post conditions: new Item is at the top of the stack.
  • 8. PSEUDO CODE IN C Void push() { int item; printf(“Enter item to push”); scanf(“%d”.&item); if(top == max – 1) { // overflow condition printf(“Stack overflow”); } else { top = top + 1; stack[top] = item; } }
  • 10. POP OPERATION  Stack is not empty, then top is at last position (n-1).  Removes top Item from stack and returns it in item.  Always done on the top of stack  The top most element is deleted first  Preconditions: Stack has been initialized and is not empty.  Post conditions: Top element has been removed from stack and item is a copy of the removed element.
  • 11. PSEUDO CODE IN C Void pop () { if(top == -1) printf(“Stack underflow”); else { printf(“The deleted item is %d”,stack[top]); top--; } }
  • 13. STACK OVERFLOW  The condition resulting from trying to push an element onto a full stack.  Top is at last position(n-1).
  • 14. STACK UNDERFLOW  The condition resulting from trying to pop an empty stack.  Top is at -1 position.
  • 15. IMPLEMENTING OF STACK Basics two choices:-  Array  Linked list 1) Array:- Array is quick, but limited in size.
  • 16. IMPLEMENTING OF STACK 2) Linked list:- Linked List requires overhead to allocate, link, unlink, and deallocate, but is not limited in size
  • 17. INFIX EXPRESSION  Operator is used in between operands.  Example:-
  • 18. POSTFIX EXPRESSION  Operator is used after operands.  Example:-
  • 19. PREFIX EXPRESSION  Operator is used before operands.  Example:-
  • 20. POLISH NOTATION  Prefix notation requires that all operators precede the two operands that they work on.  Postfix notation requires that its operators come after the corresponding operands.
  • 22. INFIX TO POSTFIX  The infix string from left to right.  Initialize an empty stack.  Character is an operand, add it to the Postfix string.  If the stack is empty, push the character is an operator to stack  stack is not empty, compare the precedence of the character with the element on top of the stack.
  • 23. EXAMPLE OF INFIX TO POSTFIX
  • 24. INFIX TO PREFIX  Reverse given prefix expression.  Conversion same as infix to postfix expression.  Reverse the expression.
  • 25. EXAMPLE OF INFIX TO PREFIX
  • 26. EVALUATION OF POSTFIX  Create a stack to store operands (or values).  If the element is a number, push it into the stack.  If the element is a operator, pop operands for the operator from stack.  Evaluate the operator and push the result back to the stack when the expression is ended, the number in the stack is the final answer.
  • 28. EVALUATION OF PREFIX  Accept a prefix string from the user.  The string from the right one character at a time.  If it is an operand, push it in stack.  If it is an operator, pop and perform the operation, specified by the operator.  Push the result in the stack.  The number in stack is final answer.
  • 30. APPLICATIONS  Parsing  Recursive Function  Calling Function  Expression Evaluation  Expression Conversion  Infix to Postfix  Infix to Prefix  Postfix to Infix  Prefix to Infix