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
Ad

More Related Content

What's hot (20)

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

Viewers also liked (20)

Splay Tree
Splay TreeSplay Tree
Splay Tree
Dr Sandeep Kumar Poonia
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
 
Data Structure
Data StructureData Structure
Data Structure
Karthikeyan A K
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
dplunkett
 
B tree &amp;
B tree &amp;B tree &amp;
B tree &amp;
memonayounas
 
stack and queue array implementation in java.
stack and queue array implementation in java.stack and queue array implementation in java.
stack and queue array implementation in java.
CIIT Atd.
 
B trees and_b__trees
B trees and_b__treesB trees and_b__trees
B trees and_b__trees
Rakhi Srivastava
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
Bangabandhu Sheikh Mujibur Rahman Science and Technology University
 
04 ds and algorithm session_05
04 ds and algorithm session_0504 ds and algorithm session_05
04 ds and algorithm session_05
Niit Care
 
07 ds and algorithm session_10
07 ds and algorithm session_1007 ds and algorithm session_10
07 ds and algorithm session_10
Niit Care
 
Lec6 mod linked list
Lec6 mod linked listLec6 mod linked list
Lec6 mod linked list
Ibrahim El-Torbany
 
B tree long
B tree longB tree long
B tree long
Nikhil Sharma
 
Chap 13(dynamic memory allocation)
Chap 13(dynamic memory allocation)Chap 13(dynamic memory allocation)
Chap 13(dynamic memory allocation)
Bangabandhu Sheikh Mujibur Rahman Science and Technology University
 
B tree
B treeB tree
B tree
Rajendran
 
05 ds and algorithm session_07
05 ds and algorithm session_0705 ds and algorithm session_07
05 ds and algorithm session_07
Niit Care
 
Organizmat njëqelizorë Aleksia Guranjaku Klasa IX shkolla "Albanet"
Organizmat njëqelizorë Aleksia Guranjaku Klasa IX shkolla "Albanet"Organizmat njëqelizorë Aleksia Guranjaku Klasa IX shkolla "Albanet"
Organizmat njëqelizorë Aleksia Guranjaku Klasa IX shkolla "Albanet"
lira kuca
 
Linked Lists
Linked ListsLinked Lists
Linked Lists
Hafiz Umair
 
Ad

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

Linked list
Linked list Linked list
Linked list
Arbind Mandal
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
Khuram Shahzad
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
 
Lecture ............ 3 - Linked Lists.pptx
Lecture ............ 3 - Linked Lists.pptxLecture ............ 3 - Linked Lists.pptx
Lecture ............ 3 - Linked Lists.pptx
SumeetRathi5
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
AravindAnand21
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
JITTAYASHWANTHREDDY
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
Hanif Durad
 
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.pptLINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
Farhana859326
 
Data Structure
Data StructureData Structure
Data Structure
HarshGupta663
 
linkedlistforslideshare-210123143943.pptx
linkedlistforslideshare-210123143943.pptxlinkedlistforslideshare-210123143943.pptx
linkedlistforslideshare-210123143943.pptx
shesnasuneer
 
Lecture 3 List of Data Structures & Algorithms
Lecture 3 List of Data Structures & AlgorithmsLecture 3 List of Data Structures & Algorithms
Lecture 3 List of Data Structures & Algorithms
haseebanjum2611
 
Linked list
Linked listLinked list
Linked list
A. S. M. Shafi
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptx
msohail37
 
LinkedList1LinkedList1LinkedList1111.pdf
LinkedList1LinkedList1LinkedList1111.pdfLinkedList1LinkedList1LinkedList1111.pdf
LinkedList1LinkedList1LinkedList1111.pdf
timoemin50
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
linked-list.ppt
linked-list.pptlinked-list.ppt
linked-list.ppt
DikkySuryadiSKomMKom
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
 
Linked list and its operations - Traversal
Linked list and its operations - TraversalLinked list and its operations - Traversal
Linked list and its operations - Traversal
kasthurimukila
 
Revisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queueRevisiting a data structures in detail with linked list stack and queue
Revisiting a data structures in detail with linked list stack and queue
ssuser7319f8
 
linkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptxlinkedlist-130914084342-phpapp02.pptx
linkedlist-130914084342-phpapp02.pptx
MeghaKulkarni27
 
Lecture ............ 3 - Linked Lists.pptx
Lecture ............ 3 - Linked Lists.pptxLecture ............ 3 - Linked Lists.pptx
Lecture ............ 3 - Linked Lists.pptx
SumeetRathi5
 
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.pptLINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
LINKEDb2bb22bb3b3b3b3n3_LIST_UKL_1-2.ppt
Farhana859326
 
linkedlistforslideshare-210123143943.pptx
linkedlistforslideshare-210123143943.pptxlinkedlistforslideshare-210123143943.pptx
linkedlistforslideshare-210123143943.pptx
shesnasuneer
 
Lecture 3 List of Data Structures & Algorithms
Lecture 3 List of Data Structures & AlgorithmsLecture 3 List of Data Structures & Algorithms
Lecture 3 List of Data Structures & Algorithms
haseebanjum2611
 
DS_LinkedList.pptx
DS_LinkedList.pptxDS_LinkedList.pptx
DS_LinkedList.pptx
msohail37
 
LinkedList1LinkedList1LinkedList1111.pdf
LinkedList1LinkedList1LinkedList1111.pdfLinkedList1LinkedList1LinkedList1111.pdf
LinkedList1LinkedList1LinkedList1111.pdf
timoemin50
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
Lec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdfLec-4_Linked-List (1).pdf
Lec-4_Linked-List (1).pdf
KylaMaeGarcia1
 
Linked list and its operations - Traversal
Linked list and its operations - TraversalLinked list and its operations - Traversal
Linked list and its operations - Traversal
kasthurimukila
 
Ad

More from Adam Mukharil Bachtiar (20)

Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
Clean Code - Formatting Code
Clean Code - Formatting CodeClean Code - Formatting Code
Clean Code - Formatting Code
Adam Mukharil Bachtiar
 
Clean Code - Clean Comments
Clean Code - Clean CommentsClean Code - Clean Comments
Clean Code - Clean Comments
Adam Mukharil Bachtiar
 
Clean Method
Clean MethodClean Method
Clean Method
Adam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
Model Driven Software Development
Model Driven Software DevelopmentModel Driven Software Development
Model Driven Software Development
Adam Mukharil Bachtiar
 
Scrum: How to Implement
Scrum: How to ImplementScrum: How to Implement
Scrum: How to Implement
Adam Mukharil Bachtiar
 
Pengujian Perangkat Lunak
Pengujian Perangkat LunakPengujian Perangkat Lunak
Pengujian Perangkat Lunak
Adam Mukharil Bachtiar
 
Data Mining Clustering
Data Mining ClusteringData Mining Clustering
Data Mining Clustering
Adam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
Adam Mukharil Bachtiar
 
UML dan Use Case View
UML dan Use Case ViewUML dan Use Case View
UML dan Use Case View
Adam Mukharil Bachtiar
 
Materi 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdfMateri 8 - Data Mining Association Rule.pdf
Materi 8 - Data Mining Association Rule.pdf
Adam Mukharil Bachtiar
 
Clean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful NamesClean Code and Design Pattern - Meaningful Names
Clean Code and Design Pattern - Meaningful Names
Adam Mukharil Bachtiar
 
Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)Data Mining Klasifikasi (Updated 30 Desember 2020)
Data Mining Klasifikasi (Updated 30 Desember 2020)
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and ConquerAnalisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
Adam Mukharil Bachtiar
 
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute ForceAnalisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Adam Mukharil Bachtiar
 
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi AlgoritmaAnalisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Adam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
Adam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Adam Mukharil Bachtiar
 

Recently uploaded (20)

Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 

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