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

PPT
Stack data structures with definition and code
PDF
Chapter 5 Stack and Queue.pdf
PPTX
The presentation on stack data structure
PDF
STACK ( LIFO STRUCTURE) - Data Structure
PDF
04 stacks
PPT
PPTX
Abscddnddmdkwkkstack implementation.pptx
PPTX
Stack data structure
Stack data structures with definition and code
Chapter 5 Stack and Queue.pdf
The presentation on stack data structure
STACK ( LIFO STRUCTURE) - Data Structure
04 stacks
Abscddnddmdkwkkstack implementation.pptx
Stack data structure

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

PPTX
Introduction to stack
PPT
Data structure lecture7
PPT
Lect 15-16 Zaheer Abbas
PPTX
DS UNIT 2 PPT.pptx stack queue representations
PPTX
Lecture#5 - Stack ADT.pptx
PDF
PPTX
DSEC1.pptx stack exchange communities that I am not 🚭 hi nahi
PPTX
Data Structure.pptx
PPTX
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
PPT
Stacks
PPTX
stacks and queues
PPTX
Stack and its applications
PPTX
Stacks and queues using aaray line .pptx
PPT
Lec 4 Stack of Data Structures & Algorithms
PPTX
Stack and Queue.pptx university exam preparation
PPTX
DATA STRUCTURE - STACK
PPTX
Stack,queue and linked list data structure.pptx
PPSX
Data structure_Stack Introduction & app.
PPTX
DS-UNIT 3 FINAL.pptx
PDF
chapter10-queue-161018120329.pdf
Introduction to stack
Data structure lecture7
Lect 15-16 Zaheer Abbas
DS UNIT 2 PPT.pptx stack queue representations
Lecture#5 - Stack ADT.pptx
DSEC1.pptx stack exchange communities that I am not 🚭 hi nahi
Data Structure.pptx
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
Stacks
stacks and queues
Stack and its applications
Stacks and queues using aaray line .pptx
Lec 4 Stack of Data Structures & Algorithms
Stack and Queue.pptx university exam preparation
DATA STRUCTURE - STACK
Stack,queue and linked list data structure.pptx
Data structure_Stack Introduction & app.
DS-UNIT 3 FINAL.pptx
chapter10-queue-161018120329.pdf

More from MarlonMagtibay2 (15)

PPTX
informationmanagement-130518152950-phpapp01.pptx
PDF
arrays-130116232821-phpapp02.pdf
PPT
CS4961-L1.ppt
PPT
CS4961-L9.ppt
PPTX
Data Structure - Stack.pptx
PPT
Lecture_Computer_Codes.ppt
PPT
lecture3_dec_bin_1.ppt
PPT
Lec2_NumberSystems.ppt
PPT
Arithmetic.ppt
PPT
binary-numbers.ppt
PPT
01.NumberSystems.ppt
PPT
lect1.ppt
PPT
renewablle energy.ppt
PPT
ch04.ppt
PDF
lecture01_Introduction.pdf
informationmanagement-130518152950-phpapp01.pptx
arrays-130116232821-phpapp02.pdf
CS4961-L1.ppt
CS4961-L9.ppt
Data Structure - Stack.pptx
Lecture_Computer_Codes.ppt
lecture3_dec_bin_1.ppt
Lec2_NumberSystems.ppt
Arithmetic.ppt
binary-numbers.ppt
01.NumberSystems.ppt
lect1.ppt
renewablle energy.ppt
ch04.ppt
lecture01_Introduction.pdf

Recently uploaded (20)

PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
STL Containers in C++ : Sequence Container : Vector
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
MCP Security Tutorial - Beginner to Advanced
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Custom Software Development Services.pptx.pptx
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Types of Token_ From Utility to Security.pdf
Complete Guide to Website Development in Malaysia for SMEs
Why Generative AI is the Future of Content, Code & Creativity?
How to Use SharePoint as an ISO-Compliant Document Management System
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
STL Containers in C++ : Sequence Container : Vector
wealthsignaloriginal-com-DS-text-... (1).pdf
MCP Security Tutorial - Beginner to Advanced
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Advanced SystemCare Ultimate Crack + Portable (2025)
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Oracle Fusion HCM Cloud Demo for Beginners
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
iTop VPN Crack Latest Version Full Key 2025
Custom Software Development Services.pptx.pptx
DNT Brochure 2025 – ISV Solutions @ D365
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Time Tracking Features That Teams and Organizations Actually Need
Types of Token_ From Utility to Security.pdf

chapter8-stack-161018120225.pdf