SlideShare a Scribd company logo
Stack
Assigned By:
Sir OmarFarooq
Subject:
DataStructure &Algorithm (CSIT-405)
Presented By
Irfan ALI
A stack is a linear data structure that stores
items in a Last-In/First-Out (LIFO) or First-
In/Last-Out (FILO) manner. In stack, a new
element is added at one end and an element
is removed from that end only. The insert
and delete operations are often called push
and pop.
Stack
A user mayinsert objectsinto astack atany time, butmay
only accessorremove the most recentlyinserted object
 push. In stack isputting an itemon topof the stack.
 pop.in astack istaking out the topitemin the stack.
Empty
Stack
Push Push
Push Push
Implementing Stacks
Stack Methods
Therearevarious functions that areassociated with a stack.Theyare,
 push()
 pop()
 top()
 display()
1. push() pushes an elementonto the stack. It becomes the new
topelement.
Push 
Result
2. pop() returns the element atthe topof the stack and removes it
from the stack. The element just below it becomes the new top
element.
Pop 
Result
3. top() returns the element atthe topof the stack.
Top 
Result
4. display() to display the wholelist.
Display 
Result
Complete
Code
Complete
Code
ThankYou!

More Related Content

What's hot

STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
Pulkitmodi1998
 
basics of queues
basics of queuesbasics of queues
basics of queues
sirmanohar
 
Data structure day3
Data structure day3Data structure day3
Data structure day3
Mohammed Elsdody
 
Stack project
Stack projectStack project
Stack project
Amr Aboelgood
 
Stack
StackStack
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
Sheikh Monirul Hasan
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
Saqib Saeed
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
Afaq Mansoor Khan
 
Queue
QueueQueue
Queue
QueueQueue
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
Stack & queue
Stack & queueStack & queue
Stack & queue
Siddique Ibrahim
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
Sagacious IT Solution
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
AndiNurkholis1
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
AndiNurkholis1
 
Stacks
StacksStacks
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
B Liyanage Asanka
 

What's hot (20)

STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
basics of queues
basics of queuesbasics of queues
basics of queues
 
Data structure day3
Data structure day3Data structure day3
Data structure day3
 
Stack project
Stack projectStack project
Stack project
 
Stack
StackStack
Stack
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Stack & queue
Stack & queueStack & queue
Stack & queue
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 
Stacks
StacksStacks
Stacks
 
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
 

Similar to Stack converted

stack coding.pptx
stack coding.pptxstack coding.pptx
stack coding.pptx
JamJahanzaib
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
Praveen Vishwakarma
 
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdfWhy does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
kesav24
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
chetan handa
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
tristans3
 
Lect 15-16 Zaheer Abbas
Lect 15-16 Zaheer  AbbasLect 15-16 Zaheer  Abbas
Lect 15-16 Zaheer Abbas
Information Technology Center
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
Ravi Khokhar
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with example
NamanKikani
 
Stack PPT.pptx
Stack PPT.pptxStack PPT.pptx
Stack PPT.pptx
UzmaRizvi5
 
Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
SLekshmiNair
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
Digvijay Singh Karakoti
 
Lecture5
Lecture5Lecture5
Lecture5
Muhammad Zubair
 
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
Shivam Kumar
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
line24arts
 
Explain what does the following function do void foo (Stack s) { .pdf
Explain what does the following function do  void foo (Stack s)  {  .pdfExplain what does the following function do  void foo (Stack s)  {  .pdf
Explain what does the following function do void foo (Stack s) { .pdf
meerobertsonheyde608
 
Stack and its operations, Queue and its operations
Stack and its operations, Queue and its operationsStack and its operations, Queue and its operations
Stack and its operations, Queue and its operations
poongothai11
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
V.V.Vanniaperumal College for Women
 
Chapter 5-stack.pptx
Chapter 5-stack.pptxChapter 5-stack.pptx
Chapter 5-stack.pptx
Halid Assen
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
Devyani Chaudhari
 
stack 1.pdf
stack 1.pdfstack 1.pdf
stack 1.pdf
hafsa40
 

Similar to Stack converted (20)

stack coding.pptx
stack coding.pptxstack coding.pptx
stack coding.pptx
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdfWhy does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
 
Lect 15-16 Zaheer Abbas
Lect 15-16 Zaheer  AbbasLect 15-16 Zaheer  Abbas
Lect 15-16 Zaheer Abbas
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with example
 
Stack PPT.pptx
Stack PPT.pptxStack PPT.pptx
Stack PPT.pptx
 
Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Lecture5
Lecture5Lecture5
Lecture5
 
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
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
 
Explain what does the following function do void foo (Stack s) { .pdf
Explain what does the following function do  void foo (Stack s)  {  .pdfExplain what does the following function do  void foo (Stack s)  {  .pdf
Explain what does the following function do void foo (Stack s) { .pdf
 
Stack and its operations, Queue and its operations
Stack and its operations, Queue and its operationsStack and its operations, Queue and its operations
Stack and its operations, Queue and its operations
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
Chapter 5-stack.pptx
Chapter 5-stack.pptxChapter 5-stack.pptx
Chapter 5-stack.pptx
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
 
stack 1.pdf
stack 1.pdfstack 1.pdf
stack 1.pdf
 

Recently uploaded

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
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
 

Recently uploaded (20)

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
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
 

Stack converted