Upload
truongnga
View
235
Download
0
Embed Size (px)
Citation preview
ADT(Abstract Data Type)BY DE ROSAL IGN. MOSES S.
What is ADT?
ADT defined in terms of its data items and associated operations, not its
implementation.
In other word, ADT must have data +
operation (function)
Data
Abstract Data Type
Operations
Analogy of ADT
Student
nim = 12345
name=Dul
createStudent
showStudent
Data
Operation
ADT in C Programming
We can use struct for data and procedure or function for operations
One ADT in one directory:
Specification : header.h
Body of primitives : .c
Test driver as main
ADT specification never contains variables
Variable declaration in the main program that uses ADT
ADT of Object Collection
Array/ Table
2 dimensional array /Matrix
Linear list
Stack
Queue
Tree
STACK
What is Stack?
Basically way to store information
The characteristic is LIFO (Last In First Out)
Stack has two main behaviors:
PUSH : Add item to top
POP : Remove item to top
Stack Pointer always points to the top
element
Top element called TOP
TOP is the only address where the operation occurs
5
4
3
2
1
Top
Bottom
Stack
Pointer
Ilustration of Stack
5
3
1
Top
Bottom
Stack
Pointer
Push(1)
Push(3)
Push(5)
Pop()
Pop()
NULL
Stack Implementation In C
With Array (Static memory allocation)
Declaration
Main Program
Function push
Function pop
Function show
Result
Function Show
ADT - Stack
ADT Stack in C
Referensi
Diktat Struktur Data ITB edisi 2008
Introduction to Data Structure/ IF2030 Algoritma dan Struktur Data 2009
Stack(tumpukan), Tim PengajarIF2030, 2009
Youtube Video (Data Structures-Abstract Data Type (ADT))
Youtube Video (What is a Stack Data
Structure - An Introduction to Stacks)
THANKS