SlideShare a Scribd company logo
STACK
Adam M.B.
DEFINITION

Stack
Stack is data structure whose its elemen
can be added and taken only from last
position (top).
Components of Stack
• Top is a variable which refers to last
position in stack.
• Element is component which has data.
• MaxStack is variable that describes
maximum number of elements in a stack.
DECLARATION

Declaration as Array
Kamus:
Const
MaxStack = value {value is integer number}
Type
NamaStack = array [1..MaxStack] of tipedata
Stack : NamaStack
Top : integer {pointer of stack}
Declaration as List
Kamus:
Type
NamaPointer = ↑Stack
Stack = Record
< MedanData : TipeData,
MedanSambungan : NamaPointer >
EndRecord
Top : NamaPointer {pointer of stack}
OPERATION

Operation
• Initialization
• Empty Operation
• Full Operation (array)/One Node
Operation (Linked List)
• Push
• Pop
Main Operation
PUSH
STACK
Take data from
element in
stack
POP
Add data to
element in
stack.
Kinds of Operation
• Stack Operation in array form
• Stack Operation in Linked list form
STACK OPERATION IN
ARRAY FORM

Operation that give a initial value for top
pointer in stack with the following rules:
• Give 0 if the first element starts from 1
• Give -1 if the first element starts from 0
Initialization
Operation that returns true if the top
pointer have 0 or -1 as its value (depend
on initialization) or returns false to the
contrary.
Empty Operation
Operation that returns true if top have
reached maximum array or maximum
array -1 (depend on initialization) or
returns false if top is not equal to
maximum array.
Full Operation
Steps in push operation:
• Stack can be added when it’s not full
• Add the top pointer with 1
• Stack element, which was refered by
top pointer, is filled with new data.
Push
Push
1
2
3
4
0
Top
Push(Top,Stack,8)
Push(Top,Stack,3)
Push(Top,Stack,5)
Push(Top,Stack,1)
Push(Top,Stack,7)
8
3
5
1
“Stack Penuh”
Stack
Steps in pop operation:
• Stack can be pop when its elements is
not empty.
• Element that have taken out from stack
is saved in a variable.
• Substract the top pointer with 1.
Pop
Pop
1
2
3
4
0
Top
Pop(Top,Stack,Elemen)
Pop(Top,Stack,Elemen)
Pop(Top,Stack,Elemen)
Pop(Top,Stack,Elemen)
Pop(Top,Stack,Elemen)
8
3
5
1
“Stack Kosong”
Stack 1
Elemen
5
3
8
STACK OPERATION IN
LINKED LIST FORM

Prepare stack by giving null value to
the top pointer in stack.
Initialization
Operation that returns true if the top
pointer isn’t null or returns false to the
contrary.
Empty Operation
Operation that returns true if right
connection field has null value (stack only
has one node) or returns false to the
contrary.
One Node Operation
Steps of push operation in linked list form
is similar with front insertion.
Push
Push
 Push(Top,8)
baru 8
Top
 Push(Top,3)
baru 3 8
Top
Push
 Push(Top,5)
baru 3 8
Top
5
Steps of pop operation in linked list form
is similar with front deletion.
Pop
Pop
 Pop(Top,Elemen)
Phapus
3 8
Top
5
Elemen
Pop
 Pop(Top,Elemen)
Phapus
3 8
Top
Elemen
Pop
 Pop(Top,Elemen)
Phapus
8
Top
Elemen
Do the task 6.27 until 6.29 in page 210 at
Data Structures book, seymour.
Exercise
Contact Person:
Adam Mukharil Bachtiar
Informatics Engineering UNIKOM
Jalan Dipati Ukur Nomor. 112-114 Bandung 40132
Email: adfbipotter@gmail.com
Blog: http://adfbipotter.wordpress.com
Copyright © Adam Mukharil Bachtiar 2012

More Related Content

Similar to chapter8-stack-161018120225.pdf

Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
SLekshmiNair
 
Stack
StackStack
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
SajalFayyaz
 
Stacks
StacksStacks
Stacks
sweta dargad
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
EktaVaswani2
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
Ahsan Mansiv
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
RAtna29
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
Devyani Chaudhari
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
prakashvs7
 
chapter10-queue-161018120329.pdf
chapter10-queue-161018120329.pdfchapter10-queue-161018120329.pdf
chapter10-queue-161018120329.pdf
ssuserff72e4
 
Stacks
StacksStacks
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
rupam100
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
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
Balwant Gorad
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
Dabbal Singh Mahara
 
Data Structure Lecture 2
Data Structure Lecture 2Data Structure Lecture 2
Data Structure Lecture 2
Teksify
 
DSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUEDSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
UshaP15
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
Muhazzab Chouhadry
 

Similar to chapter8-stack-161018120225.pdf (20)

Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
 
Stack
StackStack
Stack
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Stacks
StacksStacks
Stacks
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
 
chapter10-queue-161018120329.pdf
chapter10-queue-161018120329.pdfchapter10-queue-161018120329.pdf
chapter10-queue-161018120329.pdf
 
Stacks
StacksStacks
Stacks
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
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
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
 
Data Structure Lecture 2
Data Structure Lecture 2Data Structure Lecture 2
Data Structure Lecture 2
 
DSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUEDSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUE
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 

More from MarlonMagtibay2

informationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptxinformationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptx
MarlonMagtibay2
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdf
MarlonMagtibay2
 
CS4961-L1.ppt
CS4961-L1.pptCS4961-L1.ppt
CS4961-L1.ppt
MarlonMagtibay2
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
MarlonMagtibay2
 
Data Structure - Stack.pptx
Data Structure - Stack.pptxData Structure - Stack.pptx
Data Structure - Stack.pptx
MarlonMagtibay2
 
Lecture_Computer_Codes.ppt
Lecture_Computer_Codes.pptLecture_Computer_Codes.ppt
Lecture_Computer_Codes.ppt
MarlonMagtibay2
 
lecture3_dec_bin_1.ppt
lecture3_dec_bin_1.pptlecture3_dec_bin_1.ppt
lecture3_dec_bin_1.ppt
MarlonMagtibay2
 
Lec2_NumberSystems.ppt
Lec2_NumberSystems.pptLec2_NumberSystems.ppt
Lec2_NumberSystems.ppt
MarlonMagtibay2
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
MarlonMagtibay2
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
MarlonMagtibay2
 
01.NumberSystems.ppt
01.NumberSystems.ppt01.NumberSystems.ppt
01.NumberSystems.ppt
MarlonMagtibay2
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
MarlonMagtibay2
 
renewablle energy.ppt
renewablle energy.pptrenewablle energy.ppt
renewablle energy.ppt
MarlonMagtibay2
 
ch04.ppt
ch04.pptch04.ppt
ch04.ppt
MarlonMagtibay2
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdf
MarlonMagtibay2
 

More from MarlonMagtibay2 (15)

informationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptxinformationmanagement-130518152950-phpapp01.pptx
informationmanagement-130518152950-phpapp01.pptx
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdf
 
CS4961-L1.ppt
CS4961-L1.pptCS4961-L1.ppt
CS4961-L1.ppt
 
CS4961-L9.ppt
CS4961-L9.pptCS4961-L9.ppt
CS4961-L9.ppt
 
Data Structure - Stack.pptx
Data Structure - Stack.pptxData Structure - Stack.pptx
Data Structure - Stack.pptx
 
Lecture_Computer_Codes.ppt
Lecture_Computer_Codes.pptLecture_Computer_Codes.ppt
Lecture_Computer_Codes.ppt
 
lecture3_dec_bin_1.ppt
lecture3_dec_bin_1.pptlecture3_dec_bin_1.ppt
lecture3_dec_bin_1.ppt
 
Lec2_NumberSystems.ppt
Lec2_NumberSystems.pptLec2_NumberSystems.ppt
Lec2_NumberSystems.ppt
 
Arithmetic.ppt
Arithmetic.pptArithmetic.ppt
Arithmetic.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
01.NumberSystems.ppt
01.NumberSystems.ppt01.NumberSystems.ppt
01.NumberSystems.ppt
 
lect1.ppt
lect1.pptlect1.ppt
lect1.ppt
 
renewablle energy.ppt
renewablle energy.pptrenewablle energy.ppt
renewablle energy.ppt
 
ch04.ppt
ch04.pptch04.ppt
ch04.ppt
 
lecture01_Introduction.pdf
lecture01_Introduction.pdflecture01_Introduction.pdf
lecture01_Introduction.pdf
 

Recently uploaded

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 

Recently uploaded (20)

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 

chapter8-stack-161018120225.pdf