SlideShare a Scribd company logo
Dynamic Array and
Linked List
Adam M.B.
DYNAMIC
ARRAY
๏‚Œ๏‚
DEFINITION
AND
DECLARATION
๏‚Œ๏‚๏‚Ž
Array which can be managed dynamically
in memory (its size). To order the place in
memory, it uses POINTER.
Description
Declaration
Type
Pengenal = โ†‘Simpul
Simpul = TipeData
Atau
NamaVariabel : โ†‘TipeData
Example (1)
Kamus:
Bilangan : โ†‘integer
Nama : โ†‘string
Example (2)
Kamus:
Type
Point = โ†‘Data
Data = Record
< Nim : integer,
Nama : string,
Nilai : real >
EndRecord
DataMhs : point
ALLOC AND
DEALLOC
๏‚Œ๏‚๏‚Ž
Definition
โ€ข Alloc is statement that can be used
to order place in memory while program
is running.
โ€ข Dealloc is statement that can be
used to delete place which had been
ordered while program is running.
Ilustration in Memory
Alloc(DataMhs)
Still Empty
DataMhs
Nil
OPERATION
๏‚Œ๏‚๏‚Ž
Case
Kamus:
Type
Point = โ†‘Data
Data = Record
< NamaMhs : string,
Jurusan : string >
EndRecord
T1,T2: point
Copy Pointer (Contโ€™d)
Alloc(T1)
Alloc(T2)
T2
T1
Copy Pointer (Contโ€™d)
T1๏ƒก.NamaMhs ๏ƒŸ โ€˜Adamโ€™
T1๏ƒก.Jurusan ๏ƒŸ โ€˜Teknik Informatikaโ€™
T2
T1
Copy Pointer (Contโ€™d)
T2
T1
T2 ๏ƒŸ T1
Copy Value
T1
T2๏ƒก ๏ƒŸ T1๏ƒก
T2
Delete the Pointer
Dealloc(T1)
LINKED LIST
๏‚Œ๏‚
DEFINITION
๏‚Œ๏‚๏‚Ž
Data structure that is prepared
sequentially, dynamically, and
infinite. Linked list is connected by
pointer.
Description
Array VS Linked List
ARRAY LINKED LIST
Static Dynamic
Insert and Delete are finite Insert and Delete are infinite
Random Access Sequential Access
Delete element is only delete value
Delete element is truly delete
space
โ€ข Single Linked List
โ€ข Double Linked List
โ€ข Circular Linked List
Types of Linked List
DECLARATION
(Single Linked List)
๏‚Œ๏‚๏‚Ž
Linked list that its node consists of one
link/pointer that refers to another node.
Ilustration of node:
Description
Info Field (Info) Connection
Field (Next)
Declaration
Kamus:
Type
NamaPointer = โ†‘Simpul
Simpul = Record
< InfoField : TipeData,
ConnectionField : NamaPointer >
EndRecord
NamaVarPointer : NamaPointer
Example
Kamus:
Type
Point = โ†‘Simpul
Simpul = Record
< Info : integer,
Next : Point >
EndRecord
Awal,Akhir : Point
OPERATION
๏‚Œ๏‚๏‚Ž
โ€ข Creation
โ€ข Insertion
โ€ข Delete
โ€ข Traversal
โ€ข Searching
โ€ข Sorting
โ€ข Destroy
Pointer (awal and akhir) is given nil as
their value.
Creation
awal akhir
awal ๏ƒŸ nil akhir ๏ƒŸ nil
โ€ข If list is empty (awal = nil).
Front Insertion
baru
baru 1
baru 1
awal akhir
alloc(baru)
baru๏ƒก.next ๏ƒŸ nil
baru๏ƒก.info ๏ƒŸ 1
awal ๏ƒŸ baru
akhir ๏ƒŸ baru
โ€ข If list isnโ€™t empty (awal โ‰  nil). For example,
there is list that has two nodes:
Front Insertion (contโ€™d)
akhirawal
2 3
One node will be inserted in front of list:
1baru
alloc(baru)
baru๏ƒก.info ๏ƒŸ 1
New node will be inserted before the node that
was refered by awal.
Front Insertion (contโ€™d)
baru 1
awal
2
akhir
3
baruโ†‘.next ๏ƒŸ awal
After new node was inserted, move awal to new
node.
Front Insertion (contโ€™d)
awal
2 3
baru 1
akhir
awal ๏ƒŸ baru
The last result for front insertion if linked list
wasnโ€™t empty:
Front Insertion (contโ€™d)
baru 1
awal
2 3
akhir
Procedure SisipDepanSingle(Input elemen : tipedata, I/O awal, akhir :
nama_pointer)
{I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer
penunjuk akhir sudah terdifinisi}
{F.S. : menghasilkan satu simpul yang disisipkan di depan pada single linked
list}
Kamus :
baru : nama_pointer
Algoritma :
alloc(baru)
baruโ†‘.info ๏ƒŸ elemen
If (awal = nil)
Then
baruโ†‘.next ๏ƒŸ nil
akhir ๏ƒŸ baru
Else
baruโ†‘.next ๏ƒŸ awal
EndIf
awal ๏ƒŸ baru
EndProcedure
โ€ข If list is empty (awal = nil) ๏ƒ  the
process is same as front
insertion if linked list is
empty.
Back Insertion
โ€ข If list isnโ€™t empty (awal โ‰  nil). For example,
there is list that has two nodes:
Back Insertion (contโ€™d)
awal
3 2
akhir
New node that will be inserted:
baru 1
alloc(baru)
baru๏ƒก.next ๏ƒŸ nil
baru๏ƒก.info ๏ƒŸ 1
New node will be inserted after the node that
was refered by akhir.
Back Insertion (contโ€™d)
baru 1
akhirawal
3 2 akhir๏ƒก.next๏ƒŸ baru
Move akhir to new node.
Back Insertion (contโ€™d)
akhir ๏ƒŸ baru
akhirawal
3 2
baru 1
The last result for back insertion if linked list
wasnโ€™t empty:
Back Insertion (contโ€™d)
awal
3 2
baru
1
akhir
Procedure SisipBelakangSingle(Input elemen : tipedata, I/O awal, akhir :
nama_pointer)
{I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer
penunjuk akhir sudah terdifinisi}
{F.S. : menghasilkan satu simpul yang disisipkan di belakang pada single
linked list}
Kamus :
baru : nama_pointer
Algoritma :
alloc(baru)
baruโ†‘.info ๏ƒŸ elemen
baruโ†‘.next ๏ƒŸ nil
If (awal = nil)
Then
awal ๏ƒŸ baru
Else
akhirโ†‘.next ๏ƒŸ baru
EndIf
akhir ๏ƒŸ baru
EndProcedure
โ€ข If list is empty (awal = nil) ๏ƒ  the
process is same as front
insertion if linked list is
empty.
Middle Insertion
โ€ข If list isnโ€™t empty (awal โ‰  nil).
Middle Insertion (contโ€™d)
awal
2 54
akhir
3
New node that will be inserted after 4:
baru 1
alloc(baru)
baru๏ƒก.info ๏ƒŸ 1
Search node 4 using sequential search and
bantu pointer.
Middle Insertion (contโ€™d)
bantu
baru 1
awal
2 54
akhir
3
bantu
Connect the connection field from new node to
the neighbour node of node that was refered by
bantu.
Middle Insertion (contโ€™d)
baru๏ƒก.next ๏ƒŸ bantuโ†‘.next
baru 1
awal
2 54
akhir
3
bantu
After new node was connected with node 4 then
refer the connection field of node that was
refered by bantu to new node.
Middle Insertion (contโ€™d)
bantu๏ƒก.next ๏ƒŸ baru
bantuawal
2
baru 1
4
akhir
3 5
The last result for middle insertion if linked list
wasnโ€™t empty:
Middle Insertion (contโ€™d)
bantu
baru 1
2
akhir
5
awal
43
Procedure SisipTengahSingle(Input elemen : tipedata, I/O awal, akhir :
nama_pointer)
{I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer
penunjuk akhir sudah terdifinisi}
{F.S. : menghasilkan satu simpul yang disisipkan di tengah pada single linked list}
Kamus :
baru,bantu : nama_pointer
ketemu : boolean
datasisip : tipedata
Algoritma :
If (awal = nil)
Then
alloc(baru)
baruโ†‘.info ๏ƒŸ elemen
baruโ†‘.next ๏ƒŸ nil
awal ๏ƒŸ baru
akhir ๏ƒŸ baru
Else
Input(datasisip)
bantu ๏ƒŸ awal
ketemu ๏ƒŸ false
While (not ketemu and bantu โ‰  nil) do
If (datasisip = bantuโ†‘.info)
Then
ketemu ๏ƒŸ true
Else
bantu ๏ƒŸ bantuโ†‘.next
EndIf
EndWhile
If (ketemu)
Then
alloc(baru)
baruโ†‘.info ๏ƒŸ elemen
If (bantu = akhir)
Then
sisip_belakang_single(elemen,awal,akhir)
Else
baruโ†‘.next ๏ƒŸ bantuโ†‘.next
bantuโ†‘.next ๏ƒŸ baru
EndIf
Else
Output(โ€œData yang akan disisipkan tidak adaโ€);
EndIf
EndIf
EndProcedure
โ€ข Delete one node in beggining of linked list if
linked list has only one node (awal = akhir).
Front Deletion
awal akhir
1
If deletion happens in linked list with one node
then linked list will be empty.
Front Deletion (contโ€™d)
awal akhir
phapus
elemen
1phapus
phapus ๏ƒŸ awal elemen ๏ƒŸ phapus ๏ƒก.info
dealloc(phapus)
awal ๏ƒŸ nil akhir ๏ƒŸ nil
1
awal akhir
โ€ข If linked list has more than one node (awal โ‰ 
akhir). For example, linked list has two
nodes.
Front Deletion (contโ€™d)
awal
2 3
akhir
Front Deletion (contโ€™d)
phapus
awal
2 3
akhir
elemen
awal
2 3phapus
akhir
phapus ๏ƒŸ awal elemen ๏ƒŸ phapus๏ƒก.info
awal ๏ƒŸ awal๏ƒก.next
dealloc(phapus)
The last result for front deletion if linked list has
more than one node:
Front Deletion (contโ€™d)
phapus
awal
3
akhir
2
Procedure HapusDepanSingle(Output elemen : tipedata, I/O awal, akhir : nama_pointer)
{I.S. : pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi}
{F.S. : menghasilkan single linked list yang sudah dihapus satu simpul di depan}
Kamus :
phapus : nama_pointer
Algoritma :
phapus ๏ƒŸ awal
elemen ๏ƒŸ baruโ†‘.info
If (awal = akhir)
Then
awal ๏ƒŸ nil
akhir ๏ƒŸ nil
Else
awal๏ƒŸ awal โ†‘.next
EndIf
dealloc(phapus)
EndProcedure
โ€ข Delete one node in back of linked list if
linked list has only one node (awal = akhir).
This process is same as front
deletion if linked list has
only one node.
Back Deletion
โ€ข If linked list has more than one node (awal โ‰ 
akhir). For example, linked list has three
nodes.
Back Deletion (contโ€™d)
awal
1 32
akhir
Back Deletion (contโ€™d)
phapus
awal
1 3
akhir
2
elemen
phapus phapusakhirawal
1 32
phapus ๏ƒŸ awal
elemen ๏ƒŸ akhir๏ƒก.info
phapus ๏ƒŸ phapus๏ƒก.next
phapus ๏ƒŸ phapus๏ƒก.next
akhir ๏ƒŸ phapus
Back Deletion (contโ€™d)
awal
1 3
phapus
2
akhir
akhir๏ƒก.next ๏ƒŸ nil dealloc(phapus)
The last result for back deletion if linked list has
more than one node:
Back Deletion (contโ€™d)
phapus phapusakhir
3
awal
12
Procedure HapusBelakangSingle(Output elemen : tipedata, I/O awal, akhir : nama_pointer)
{I.S. : pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi}
{F.S. : menghasilkan single linked list yang sudah dihapus satu simpul di belakang}
Kamus :
phapus : nama_pointer
Algoritma :
phapus ๏ƒŸ awal
elemen ๏ƒŸ baruโ†‘.info
If (awal = akhir)
Then
awal ๏ƒŸ nil
akhir ๏ƒŸ nil
Else
while (phapusโ†‘.next โ‰  akhir) do
phapus ๏ƒŸ phapusโ†‘.next
endwhile
akhir ๏ƒŸ phapus
phapus ๏ƒŸ phapusโ†‘.next
akhirโ†‘.next ๏ƒŸ nil
EndIf
dealloc(phapus)
EndProcedure
โ€ข Delete one node in middle of linked list if
linked list has only one node (awal = akhir).
This process is same as front
deletion if linked list has
only one node.
Middle Deletion
โ€ข If linked list has more than one node (awal โ‰ 
akhir). For example, linked list has four
nodes and user want to delete third node.
Middle Deletion (contโ€™d)
awal
2 54
akhir
3
Search the third node start from the first node.
If node is found then save the info of this node
to the variable elemen.
Middle Deletion (contโ€™d)
phapus
posisihapus=2awal
2 54
akhir
3
posisihapus=1 posisihapus=3
phapus
elemen elemen๏ƒŸphapus๏ƒก.info
Because the connection field of previous node must be
connected to the next node of node that will be
deleted so we need pointer bantu that refer the node
that will be deleted.
Middle Deletion (contโ€™d)
bantuawal
2 54
phapus akhir
3
posisihapus=3
Connect the connection field of the node that was
referred by pointer bantu to the neighbour node.
Delete the node that was referred by pointer phapus.
Middle Deletion (contโ€™d)
awal
2 54
phapus akhir
3
posisihapus=3bantu
bantu๏ƒก.next ๏ƒŸ phapus๏ƒก.next
dealloc(phapus)
The last result for middle deletion if linked list
has more than one node:
Middle Deletion (contโ€™d)
5
akhir
2
phapus
posisihapus=1posisihapus=2 posisihapus=3
phapus
bantuawal
43 43 5
akhir
awal
Operation that visiting all nodes in linked list
start from the first node until last node.
Traversal
awal
2 54
akhir
3
For example, shown the process to output data:
โ€ข Place one pointer bantu in the first node
awa
l
2 54
akhir
3
bantu
The value in info field will be output to screen from the
node that was referred by bantu then pointer bantu
will move to the next node until all nodes were visited
(bantu = nil).
Traversal
awal
2 54
akhir
3
bantu bantu bantu bantu
3 4 2 5Screen Output:
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

What's hot (20)

PPTX
Linked lists in Data Structure
Muhazzab Chouhadry
ย 
PPT
Operations on linked list
Sumathi Kv
ย 
PPTX
Linear data structure concepts
Akila Krishnamoorthy
ย 
PPTX
Mca ii dfs u-3 linklist,stack,queue
Rai University
ย 
PPTX
CSE240 Doubly Linked Lists
Garrett Gutierrez
ย 
PDF
Stacks,queues,linked-list
pinakspatel
ย 
PPTX
Linked list
VONI
ย 
PPTX
Unit 5 linked list
Dabbal Singh Mahara
ย 
PPT
linked list
Narendra Chauhan
ย 
PPTX
Data structure , stack , queue
Rajkiran Nadar
ย 
PPT
Linked list
Trupti Agrawal
ย 
PPTX
Doubly & Circular Linked Lists
Afaq Mansoor Khan
ย 
PPT
Sorting & Linked Lists
J.T.A.JONES
ย 
PPTX
linked list using c
Venkat Reddy
ย 
PPT
linked list (c#)
swajahatr
ย 
PPTX
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
ย 
PPT
Data structure lecture 5
Kumar
ย 
PPT
Linked lists
GowriKumar Chandramouli
ย 
PPTX
Linked list
RahulGandhi110
ย 
PPT
linked list
Shaista Qadir
ย 
Linked lists in Data Structure
Muhazzab Chouhadry
ย 
Operations on linked list
Sumathi Kv
ย 
Linear data structure concepts
Akila Krishnamoorthy
ย 
Mca ii dfs u-3 linklist,stack,queue
Rai University
ย 
CSE240 Doubly Linked Lists
Garrett Gutierrez
ย 
Stacks,queues,linked-list
pinakspatel
ย 
Linked list
VONI
ย 
Unit 5 linked list
Dabbal Singh Mahara
ย 
linked list
Narendra Chauhan
ย 
Data structure , stack , queue
Rajkiran Nadar
ย 
Linked list
Trupti Agrawal
ย 
Doubly & Circular Linked Lists
Afaq Mansoor Khan
ย 
Sorting & Linked Lists
J.T.A.JONES
ย 
linked list using c
Venkat Reddy
ย 
linked list (c#)
swajahatr
ย 
Data Structures - Lecture 7 [Linked List]
Muhammad Hammad Waseem
ย 
Data structure lecture 5
Kumar
ย 
Linked lists
GowriKumar Chandramouli
ย 
Linked list
RahulGandhi110
ย 
linked list
Shaista Qadir
ย 

Viewers also liked (20)

PDF
Splay Tree
Dr Sandeep Kumar Poonia
ย 
PDF
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
ย 
PPT
แž˜แŸแžšแŸ€แž“แŸˆ Data Structure and Algorithm in C/C++
Ngeam Soly
ย 
PPTX
Data Structure
Karthikeyan A K
ย 
PPT
Lecture 1 data structures and algorithms
Aakash deep Singhal
ย 
PPT
DATA STRUCTURES
bca2010
ย 
PPT
Ap Power Point Chpt6
dplunkett
ย 
PPTX
B tree &amp;
memonayounas
ย 
PPT
stack and queue array implementation in java.
CIIT Atd.
ย 
PPT
B trees and_b__trees
Rakhi Srivastava
ย 
PPS
04 ds and algorithm session_05
Niit Care
ย 
PPS
07 ds and algorithm session_10
Niit Care
ย 
PPT
Lec6 mod linked list
Ibrahim El-Torbany
ย 
PPTX
B tree long
Nikhil Sharma
ย 
PPT
B tree
Rajendran
ย 
PPS
05 ds and algorithm session_07
Niit Care
ย 
PPTX
Organizmat njรซqelizorรซ Aleksia Guranjaku Klasa IX shkolla "Albanet"
lira kuca
ย 
PPTX
Linked Lists
Hafiz Umair
ย 
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
ย 
แž˜แŸแžšแŸ€แž“แŸˆ Data Structure and Algorithm in C/C++
Ngeam Soly
ย 
Data Structure
Karthikeyan A K
ย 
Lecture 1 data structures and algorithms
Aakash deep Singhal
ย 
DATA STRUCTURES
bca2010
ย 
Ap Power Point Chpt6
dplunkett
ย 
B tree &amp;
memonayounas
ย 
stack and queue array implementation in java.
CIIT Atd.
ย 
B trees and_b__trees
Rakhi Srivastava
ย 
04 ds and algorithm session_05
Niit Care
ย 
07 ds and algorithm session_10
Niit Care
ย 
Lec6 mod linked list
Ibrahim El-Torbany
ย 
B tree long
Nikhil Sharma
ย 
B tree
Rajendran
ย 
05 ds and algorithm session_07
Niit Care
ย 
Organizmat njรซqelizorรซ Aleksia Guranjaku Klasa IX shkolla "Albanet"
lira kuca
ย 
Linked Lists
Hafiz Umair
ย 
Ad

Similar to Data Structure (Dynamic Array and Linked List) (20)

PPTX
Linked list
Arbind Mandal
ย 
PPTX
Linked lists a
Khuram Shahzad
ย 
PPTX
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
ย 
PPTX
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
ย 
PPTX
Lecture ............ 3 - Linked Lists.pptx
SumeetRathi5
ย 
PDF
Unit - 2.pdf
AravindAnand21
ย 
PPT
DS Unit 2.ppt
JITTAYASHWANTHREDDY
ย 
PPTX
Linked list
KalaivaniKS1
ย 
PPT
Chapter 5 ds
Hanif Durad
ย 
PPT
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
Farhana859326
ย 
PPTX
Data Structure
HarshGupta663
ย 
PPTX
linkedlistforslideshare-210123143943.pptx
shesnasuneer
ย 
PPT
Lecture 3 List of Data Structures & Algorithms
haseebanjum2611
ย 
PDF
Linked list
A. S. M. Shafi
ย 
PPTX
DS_LinkedList.pptx
msohail37
ย 
PDF
LinkedList1LinkedList1LinkedList1111.pdf
timoemin50
ย 
PPTX
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
ย 
PPT
linked-list.ppt
DikkySuryadiSKomMKom
ย 
PDF
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
ย 
PPTX
Linked list and its operations - Traversal
kasthurimukila
ย 
Linked list
Arbind Mandal
ย 
Linked lists a
Khuram Shahzad
ย 
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
ย 
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
ย 
Lecture ............ 3 - Linked Lists.pptx
SumeetRathi5
ย 
Unit - 2.pdf
AravindAnand21
ย 
DS Unit 2.ppt
JITTAYASHWANTHREDDY
ย 
Linked list
KalaivaniKS1
ย 
Chapter 5 ds
Hanif Durad
ย 
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
Farhana859326
ย 
Data Structure
HarshGupta663
ย 
linkedlistforslideshare-210123143943.pptx
shesnasuneer
ย 
Lecture 3 List of Data Structures & Algorithms
haseebanjum2611
ย 
Linked list
A. S. M. Shafi
ย 
DS_LinkedList.pptx
msohail37
ย 
LinkedList1LinkedList1LinkedList1111.pdf
timoemin50
ย 
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
ย 
linked-list.ppt
DikkySuryadiSKomMKom
ย 
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
ย 
Linked list and its operations - Traversal
kasthurimukila
ย 
Ad

More from Adam Mukharil Bachtiar (20)

PDF
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
ย 
PDF
Clean Code - Formatting Code
Adam Mukharil Bachtiar
ย 
PDF
Clean Code - Clean Comments
Adam Mukharil Bachtiar
ย 
PDF
Clean Method
Adam Mukharil Bachtiar
ย 
PDF
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
ย 
PDF
Model Driven Software Development
Adam Mukharil Bachtiar
ย 
PDF
Scrum: How to Implement
Adam Mukharil Bachtiar
ย 
PDF
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
ย 
PDF
Data Mining Clustering
Adam Mukharil Bachtiar
ย 
PPTX
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
ย 
PDF
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
ย 
PDF
Activity Diagram
Adam Mukharil Bachtiar
ย 
PDF
UML dan Use Case View
Adam Mukharil Bachtiar
ย 
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
ย 
Clean Code - Formatting Code
Adam Mukharil Bachtiar
ย 
Clean Code - Clean Comments
Adam Mukharil Bachtiar
ย 
Clean Method
Adam Mukharil Bachtiar
ย 
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
ย 
Model Driven Software Development
Adam Mukharil Bachtiar
ย 
Scrum: How to Implement
Adam Mukharil Bachtiar
ย 
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
ย 
Data Mining Clustering
Adam Mukharil Bachtiar
ย 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
ย 
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
ย 
Activity Diagram
Adam Mukharil Bachtiar
ย 
UML dan Use Case View
Adam Mukharil Bachtiar
ย 

Recently uploaded (20)

PPTX
WYSIWYG Web Builder Crack 2025 โ€“ Free Download Full Version with License Key
HyperPc soft
ย 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
ย 
PDF
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
ย 
PPTX
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
ย 
PPTX
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
ย 
PPTX
Cubase Pro Crack 2025 โ€“ Free Download Full Version with Activation Key
HyperPc soft
ย 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
ย 
PDF
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
PPTX
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
ย 
PPTX
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
ย 
PDF
Rewards and Recognition (2).pdf
ethan Talor
ย 
PPTX
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
ย 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
ย 
PDF
Dealing with JSON in the relational world
Andres Almiray
ย 
PDF
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
ย 
PDF
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
ย 
PDF
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
PDF
Continouous failure - Why do we make our lives hard?
Papp Krisztiรกn
ย 
PDF
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 
WYSIWYG Web Builder Crack 2025 โ€“ Free Download Full Version with License Key
HyperPc soft
ย 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
ย 
>Nitro Pro Crack 14.36.1.0 + Keygen Free Download [Latest]
utfefguu
ย 
ERP - FICO Presentation BY BSL BOKARO STEEL LIMITED.pptx
ravisranjan
ย 
Android Notifications-A Guide to User-Facing Alerts in Android .pptx
Nabin Dhakal
ย 
Cubase Pro Crack 2025 โ€“ Free Download Full Version with Activation Key
HyperPc soft
ย 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
ย 
Difference Between Kubernetes and Docker .pdf
Kindlebit Solutions
ย 
IObit Driver Booster Pro 12.4-12.5 license keys 2025-2026
chaudhryakashoo065
ย 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
ย 
IObit Driver Booster Pro Crack Download Latest Version
chaudhryakashoo065
ย 
Rewards and Recognition (2).pdf
ethan Talor
ย 
Quality on Autopilot: Scaling Testing in Uyuni
Oscar Barrios Torrero
ย 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
ย 
Dealing with JSON in the relational world
Andres Almiray
ย 
Power BI vs Tableau vs Looker - Which BI Tool is Right for You?
MagnusMinds IT Solution LLP
ย 
IDM Crack with Internet Download Manager 6.42 Build 41
utfefguu
ย 
AWS Consulting Services: Empowering Digital Transformation with Nlineaxis
Nlineaxis IT Solutions Pvt Ltd
ย 
Continouous failure - Why do we make our lives hard?
Papp Krisztiรกn
ย 
LPS25 - Operationalizing MLOps in GEP - Terradue.pdf
terradue
ย 

Data Structure (Dynamic Array and Linked List)

  • 1. Dynamic Array and Linked List Adam M.B.
  • 4. Array which can be managed dynamically in memory (its size). To order the place in memory, it uses POINTER. Description
  • 5. Declaration Type Pengenal = โ†‘Simpul Simpul = TipeData Atau NamaVariabel : โ†‘TipeData
  • 6. Example (1) Kamus: Bilangan : โ†‘integer Nama : โ†‘string
  • 7. Example (2) Kamus: Type Point = โ†‘Data Data = Record < Nim : integer, Nama : string, Nilai : real > EndRecord DataMhs : point
  • 9. Definition โ€ข Alloc is statement that can be used to order place in memory while program is running. โ€ข Dealloc is statement that can be used to delete place which had been ordered while program is running.
  • 12. Case Kamus: Type Point = โ†‘Data Data = Record < NamaMhs : string, Jurusan : string > EndRecord T1,T2: point
  • 14. Copy Pointer (Contโ€™d) T1๏ƒก.NamaMhs ๏ƒŸ โ€˜Adamโ€™ T1๏ƒก.Jurusan ๏ƒŸ โ€˜Teknik Informatikaโ€™ T2 T1
  • 20. Data structure that is prepared sequentially, dynamically, and infinite. Linked list is connected by pointer. Description
  • 21. Array VS Linked List ARRAY LINKED LIST Static Dynamic Insert and Delete are finite Insert and Delete are infinite Random Access Sequential Access Delete element is only delete value Delete element is truly delete space
  • 22. โ€ข Single Linked List โ€ข Double Linked List โ€ข Circular Linked List Types of Linked List
  • 24. Linked list that its node consists of one link/pointer that refers to another node. Ilustration of node: Description Info Field (Info) Connection Field (Next)
  • 25. Declaration Kamus: Type NamaPointer = โ†‘Simpul Simpul = Record < InfoField : TipeData, ConnectionField : NamaPointer > EndRecord NamaVarPointer : NamaPointer
  • 26. Example Kamus: Type Point = โ†‘Simpul Simpul = Record < Info : integer, Next : Point > EndRecord Awal,Akhir : Point
  • 28. โ€ข Creation โ€ข Insertion โ€ข Delete โ€ข Traversal โ€ข Searching โ€ข Sorting โ€ข Destroy
  • 29. Pointer (awal and akhir) is given nil as their value. Creation awal akhir awal ๏ƒŸ nil akhir ๏ƒŸ nil
  • 30. โ€ข If list is empty (awal = nil). Front Insertion baru baru 1 baru 1 awal akhir alloc(baru) baru๏ƒก.next ๏ƒŸ nil baru๏ƒก.info ๏ƒŸ 1 awal ๏ƒŸ baru akhir ๏ƒŸ baru
  • 31. โ€ข If list isnโ€™t empty (awal โ‰  nil). For example, there is list that has two nodes: Front Insertion (contโ€™d) akhirawal 2 3 One node will be inserted in front of list: 1baru alloc(baru) baru๏ƒก.info ๏ƒŸ 1
  • 32. New node will be inserted before the node that was refered by awal. Front Insertion (contโ€™d) baru 1 awal 2 akhir 3 baruโ†‘.next ๏ƒŸ awal
  • 33. After new node was inserted, move awal to new node. Front Insertion (contโ€™d) awal 2 3 baru 1 akhir awal ๏ƒŸ baru
  • 34. The last result for front insertion if linked list wasnโ€™t empty: Front Insertion (contโ€™d) baru 1 awal 2 3 akhir
  • 35. Procedure SisipDepanSingle(Input elemen : tipedata, I/O awal, akhir : nama_pointer) {I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi} {F.S. : menghasilkan satu simpul yang disisipkan di depan pada single linked list} Kamus : baru : nama_pointer Algoritma : alloc(baru) baruโ†‘.info ๏ƒŸ elemen If (awal = nil) Then baruโ†‘.next ๏ƒŸ nil akhir ๏ƒŸ baru Else baruโ†‘.next ๏ƒŸ awal EndIf awal ๏ƒŸ baru EndProcedure
  • 36. โ€ข If list is empty (awal = nil) ๏ƒ  the process is same as front insertion if linked list is empty. Back Insertion
  • 37. โ€ข If list isnโ€™t empty (awal โ‰  nil). For example, there is list that has two nodes: Back Insertion (contโ€™d) awal 3 2 akhir New node that will be inserted: baru 1 alloc(baru) baru๏ƒก.next ๏ƒŸ nil baru๏ƒก.info ๏ƒŸ 1
  • 38. New node will be inserted after the node that was refered by akhir. Back Insertion (contโ€™d) baru 1 akhirawal 3 2 akhir๏ƒก.next๏ƒŸ baru
  • 39. Move akhir to new node. Back Insertion (contโ€™d) akhir ๏ƒŸ baru akhirawal 3 2 baru 1
  • 40. The last result for back insertion if linked list wasnโ€™t empty: Back Insertion (contโ€™d) awal 3 2 baru 1 akhir
  • 41. Procedure SisipBelakangSingle(Input elemen : tipedata, I/O awal, akhir : nama_pointer) {I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi} {F.S. : menghasilkan satu simpul yang disisipkan di belakang pada single linked list} Kamus : baru : nama_pointer Algoritma : alloc(baru) baruโ†‘.info ๏ƒŸ elemen baruโ†‘.next ๏ƒŸ nil If (awal = nil) Then awal ๏ƒŸ baru Else akhirโ†‘.next ๏ƒŸ baru EndIf akhir ๏ƒŸ baru EndProcedure
  • 42. โ€ข If list is empty (awal = nil) ๏ƒ  the process is same as front insertion if linked list is empty. Middle Insertion
  • 43. โ€ข If list isnโ€™t empty (awal โ‰  nil). Middle Insertion (contโ€™d) awal 2 54 akhir 3 New node that will be inserted after 4: baru 1 alloc(baru) baru๏ƒก.info ๏ƒŸ 1
  • 44. Search node 4 using sequential search and bantu pointer. Middle Insertion (contโ€™d) bantu baru 1 awal 2 54 akhir 3 bantu
  • 45. Connect the connection field from new node to the neighbour node of node that was refered by bantu. Middle Insertion (contโ€™d) baru๏ƒก.next ๏ƒŸ bantuโ†‘.next baru 1 awal 2 54 akhir 3 bantu
  • 46. After new node was connected with node 4 then refer the connection field of node that was refered by bantu to new node. Middle Insertion (contโ€™d) bantu๏ƒก.next ๏ƒŸ baru bantuawal 2 baru 1 4 akhir 3 5
  • 47. The last result for middle insertion if linked list wasnโ€™t empty: Middle Insertion (contโ€™d) bantu baru 1 2 akhir 5 awal 43
  • 48. Procedure SisipTengahSingle(Input elemen : tipedata, I/O awal, akhir : nama_pointer) {I.S. : data yang akan disisipkan (elemen), pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi} {F.S. : menghasilkan satu simpul yang disisipkan di tengah pada single linked list} Kamus : baru,bantu : nama_pointer ketemu : boolean datasisip : tipedata Algoritma : If (awal = nil) Then alloc(baru) baruโ†‘.info ๏ƒŸ elemen baruโ†‘.next ๏ƒŸ nil
  • 49. awal ๏ƒŸ baru akhir ๏ƒŸ baru Else Input(datasisip) bantu ๏ƒŸ awal ketemu ๏ƒŸ false While (not ketemu and bantu โ‰  nil) do If (datasisip = bantuโ†‘.info) Then ketemu ๏ƒŸ true Else bantu ๏ƒŸ bantuโ†‘.next EndIf EndWhile
  • 50. If (ketemu) Then alloc(baru) baruโ†‘.info ๏ƒŸ elemen If (bantu = akhir) Then sisip_belakang_single(elemen,awal,akhir) Else baruโ†‘.next ๏ƒŸ bantuโ†‘.next bantuโ†‘.next ๏ƒŸ baru EndIf Else Output(โ€œData yang akan disisipkan tidak adaโ€); EndIf EndIf EndProcedure
  • 51. โ€ข Delete one node in beggining of linked list if linked list has only one node (awal = akhir). Front Deletion awal akhir 1
  • 52. If deletion happens in linked list with one node then linked list will be empty. Front Deletion (contโ€™d) awal akhir phapus elemen 1phapus phapus ๏ƒŸ awal elemen ๏ƒŸ phapus ๏ƒก.info dealloc(phapus) awal ๏ƒŸ nil akhir ๏ƒŸ nil 1 awal akhir
  • 53. โ€ข If linked list has more than one node (awal โ‰  akhir). For example, linked list has two nodes. Front Deletion (contโ€™d) awal 2 3 akhir
  • 54. Front Deletion (contโ€™d) phapus awal 2 3 akhir elemen awal 2 3phapus akhir phapus ๏ƒŸ awal elemen ๏ƒŸ phapus๏ƒก.info awal ๏ƒŸ awal๏ƒก.next dealloc(phapus)
  • 55. The last result for front deletion if linked list has more than one node: Front Deletion (contโ€™d) phapus awal 3 akhir 2
  • 56. Procedure HapusDepanSingle(Output elemen : tipedata, I/O awal, akhir : nama_pointer) {I.S. : pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi} {F.S. : menghasilkan single linked list yang sudah dihapus satu simpul di depan} Kamus : phapus : nama_pointer Algoritma : phapus ๏ƒŸ awal elemen ๏ƒŸ baruโ†‘.info If (awal = akhir) Then awal ๏ƒŸ nil akhir ๏ƒŸ nil Else awal๏ƒŸ awal โ†‘.next EndIf dealloc(phapus) EndProcedure
  • 57. โ€ข Delete one node in back of linked list if linked list has only one node (awal = akhir). This process is same as front deletion if linked list has only one node. Back Deletion
  • 58. โ€ข If linked list has more than one node (awal โ‰  akhir). For example, linked list has three nodes. Back Deletion (contโ€™d) awal 1 32 akhir
  • 59. Back Deletion (contโ€™d) phapus awal 1 3 akhir 2 elemen phapus phapusakhirawal 1 32 phapus ๏ƒŸ awal elemen ๏ƒŸ akhir๏ƒก.info phapus ๏ƒŸ phapus๏ƒก.next phapus ๏ƒŸ phapus๏ƒก.next akhir ๏ƒŸ phapus
  • 60. Back Deletion (contโ€™d) awal 1 3 phapus 2 akhir akhir๏ƒก.next ๏ƒŸ nil dealloc(phapus)
  • 61. The last result for back deletion if linked list has more than one node: Back Deletion (contโ€™d) phapus phapusakhir 3 awal 12
  • 62. Procedure HapusBelakangSingle(Output elemen : tipedata, I/O awal, akhir : nama_pointer) {I.S. : pointer penunjuk awal dan pointer penunjuk akhir sudah terdifinisi} {F.S. : menghasilkan single linked list yang sudah dihapus satu simpul di belakang} Kamus : phapus : nama_pointer Algoritma : phapus ๏ƒŸ awal elemen ๏ƒŸ baruโ†‘.info If (awal = akhir) Then awal ๏ƒŸ nil akhir ๏ƒŸ nil
  • 63. Else while (phapusโ†‘.next โ‰  akhir) do phapus ๏ƒŸ phapusโ†‘.next endwhile akhir ๏ƒŸ phapus phapus ๏ƒŸ phapusโ†‘.next akhirโ†‘.next ๏ƒŸ nil EndIf dealloc(phapus) EndProcedure
  • 64. โ€ข Delete one node in middle of linked list if linked list has only one node (awal = akhir). This process is same as front deletion if linked list has only one node. Middle Deletion
  • 65. โ€ข If linked list has more than one node (awal โ‰  akhir). For example, linked list has four nodes and user want to delete third node. Middle Deletion (contโ€™d) awal 2 54 akhir 3
  • 66. Search the third node start from the first node. If node is found then save the info of this node to the variable elemen. Middle Deletion (contโ€™d) phapus posisihapus=2awal 2 54 akhir 3 posisihapus=1 posisihapus=3 phapus elemen elemen๏ƒŸphapus๏ƒก.info
  • 67. Because the connection field of previous node must be connected to the next node of node that will be deleted so we need pointer bantu that refer the node that will be deleted. Middle Deletion (contโ€™d) bantuawal 2 54 phapus akhir 3 posisihapus=3
  • 68. Connect the connection field of the node that was referred by pointer bantu to the neighbour node. Delete the node that was referred by pointer phapus. Middle Deletion (contโ€™d) awal 2 54 phapus akhir 3 posisihapus=3bantu bantu๏ƒก.next ๏ƒŸ phapus๏ƒก.next dealloc(phapus)
  • 69. The last result for middle deletion if linked list has more than one node: Middle Deletion (contโ€™d) 5 akhir 2 phapus posisihapus=1posisihapus=2 posisihapus=3 phapus bantuawal 43 43 5 akhir awal
  • 70. Operation that visiting all nodes in linked list start from the first node until last node. Traversal awal 2 54 akhir 3 For example, shown the process to output data: โ€ข Place one pointer bantu in the first node awa l 2 54 akhir 3 bantu
  • 71. The value in info field will be output to screen from the node that was referred by bantu then pointer bantu will move to the next node until all nodes were visited (bantu = nil). Traversal awal 2 54 akhir 3 bantu bantu bantu bantu 3 4 2 5Screen Output:
  • 72. Contact Person: Adam Mukharil Bachtiar Informatics Engineering UNIKOM Jalan Dipati Ukur Nomor. 112-114 Bandung 40132 Email: [email protected] Blog: http://adfbipotter.wordpress.com Copyright ยฉ Adam Mukharil Bachtiar 2012