SlideShare une entreprise Scribd logo
1  sur  37
Heap Sort
Adam M.B.
DEFINITION

Heap
Heap
Tree
Complete
Binary Tree
(CBT)
Max Heap
Value of node
>= value of its
child
Min Heap
Value of node
<= value of its
child
Example of Heap
Max Heap Min Heap
24
19
13
15
11 5 8
4
4
5
13
8
11 19 15
24
k
2k 2k+1
2k+1 2k+12k
2k
2k
BASIC
PROCESSES

• Making of heap
• Heap sort
Processes in Heap
Making of Heap
• Shift down from middle node
(Sum of node/2) until first node
1 2 3 4
14 11 57
5 6
3 2
1
2 3
54 6
• N = 6, Middle = N/2 = 6/2 = 3
• Reorganize on third node
• Reorganize on second node
• Reorganize on first node
1 2 3 4
14 11 5 7
5 6
3 2
7
3
14 11
2
53
14
2
57
14
11
7
Heap Sort 1
a. Binary tree in Max heap state.
b. “Fired” root and swap with last
node.
c. Subtract number of nodes with
1.
d. If N > 1 then reorganize heap
again.
e. Repeat step b to d until node is
empty (N=0)
1
2 3
54 6
1 2 3 4
14 11 5 7
5 6
3 2142 14
3 2
5
14
11
7
2
Heap Sort 1
a.Binary tree in Max heap
state.
b.“Fired” root and swap with
last node.
c. Subtract number of nodes
with 1.
d.If N > 1 then reorganize
heap again.
e.Repeat step b to d until
node is empty (N=0)
1
2 3
54 6
1 2 3 4
14 11 5 7
5 6
3 2142 14
3 2
5
14
11
7
2
Heap Sort 2
Reorganize heap
Middle = N/2 = 5/2 = 2
b. “Fired” root and swap with last
node.
c. Subtract number of nodes with 1.
d. If N > 1 then reorganize heap
again.
e. Repeat step b to d until node is
empty (N=0)
Reorganize heap on second node.
Reorganize heap on first node.
1
2 3
54
3
511
7
2
1 2 3 4
11 5 7
5 6
3 2142 14
11
27
2
2
11 27 2112 11
Heap Sort 3
Reorganize heap
Middle = N/2 = 4/2 = 2
b. “Fired” root and swap with last
node.
c. Subtract number of nodes with 1.
d. If N > 1 then reorganize heap
again.
e. Repeat step b to d until node is
empty (N=0)
Reorganize heap on second node.
Reorganize heap on first node.
1
2 3
4
3
5
2
7
1 2 3 4
5 7
5 6
3 214147 2112 11
2
7
7 2
3
2
3 2
2
72 7
Heap Sort 4
Reorganize heap
Middle = N/2 = 3/2 = 1
b. “Fired” root and swap with last
node.
c. Subtract number of nodes with 1.
d. If N > 1 then reorganize heap
again.
e. Repeat step b to d until node is
empty (N=0)
Reorganize heap on first node.
1
2 3
5
2
3
1 2 3 4
5 7
5 6
3 21414211113 272 7
5
2
5 2
2
52 5
Heap Sort 5
Reorganize heap
Middle = N/2 = 2/2 = 1
b. “Fired” root and swap with last
node.
c. Subtract number of nodes with 1.
d. If N > 1 then reorganize heap
again.
e. Repeat step b to d until node is
empty (N=0)
Reorganize heap on first node.
1
2
2
3
1 2 3 4
5 7
5 6
3 21414211113 277252 5
2
3
3 2
2
32 3
Heap Sort 6
Because N = 1 then reorganize isn’t
happen.
b. “Fired” root
c. Subtract number of nodes with 1.
Because N = 0 then sorting processes is
finish.
1
2
1 2 3 4
5 7
5 6
3 21414211113 277252 52332
m
CASE

Node have 2
Case Example
Sort these name using heap sort method in
descending way. Num. Name
1 Rahmat
2 Didin
3 Ahmad
4 Joned
5 Syahrul
6 Riki
7 Arif
8 Susi
9 Donni
10 Asih
Node have 2
Making of CBT
Rahmat
AhmadDidin
Joned Syahrul Riki Arif
Susi Donni Asih
Not Heap
Complete Binary Tree
Rahmat Didin Ahmad Joned Syahrul Riki Arif Susi Donni Asih
1 2 3 4 5 6 7 8 9 10
Node have 2
Heap Sort 1
1 2 3 4 5 6 7 8 9 10
Rahmat
AhmadDidin
Joned Syahrul Riki Arif
Susi Donni Asih
Heap
Syahrul
Asih
Joned
Donni Didin
Asih Rahmat
Ahmad
Arif
Rahmat
Ahmad Asih Arif Donni Didin Riki Rahmat Susi Joned Syahrul
Node have 2
Heap Sort 2
Riki
Susi
Not Heap
SyahrulJoned
Donni Didin
Asih
Ahmad
Arif
Rahmat
Syahrul
1 2 3 4 5 6 7 8 9 10
Ahmad Asih Arif Donni Didin Riki Rahmat Susi Joned SyahrulAhmadSyahrul Ahmad
Node have 2
Heap Sort 3
Riki
Susi
Heap
Joned
Donni Didin
Asih Arif
Rahmat
SyahrulArif
SyahrulRahmat
Syahrul
1 2 3 4 5 6 7 8 9 10
Asih Arif Donni Didin Riki Rahmat Susi Joned SyahrulAhmadSyahrul AhmadArif SyahrulRahmat Syahrul
Node have 2
Heap Sort 4
Riki
Susi
Not Heap
Joned
Donni Didin
Asih
Arif
Rahmat
Syahrul
Joned
1 2 3 4 5 6 7 8 9 10
Asih Donni Didin Riki Susi Joned SyahrulAhmadAhmadArif Rahmat SyahrulJoned ArifArif
Node have 2
Heap Sort 5
Riki
Susi
Heap
Donni Didin
Asih Rahmat
Syahrul
JonedAsih
JonedDidin
Joned
1 2 3 4 5 6 7 8 9 10
Asih Donni Didin Riki Susi Joned SyahrulAhmadAhmadRahmat SyahrulJoned ArifArifJonedAsih Didin Joned
Node have 2
Heap Sort 6
Riki
Susi Not Heap
Donni
Rahmat
Syahrul
Asih
Didin
Joned
Susi
1 2 3 4 5 6 7 8 9 10
Donni Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsih Didin JonedSusi AsihAsih
Node have 2
Heap Sort 7
Riki
Heap
Donni
Rahmat
Syahrul
Didin
Joned
SusiDidin
SusiDonni
Susi
1 2 3 4 5 6 7 8 9 10
Donni Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifDidin JonedSusi AsihAsihDidin SusiDonni Susi
Node have 2
Heap Sort 8
Riki
Not Heap
Rahmat
SyahrulJoned
Didin
Donni
Susi
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifJoned AsihAsihDidin Donni SusiSyahrul DidinDidin
Node have 2
Heap Sort 9
Riki
Heap
Rahmat
Joned
Donni
Susi
SyahrulDonni
SyahrulJoned
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifJoned AsihAsihDonni SusiSyahrul DidinDidinDonni SyahrulJoned Syahrul
Node have 2
Heap Sort 10
Riki
Not Heap
Rahmat
Susi
Donni
Joned
Syahrul
Riki
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinDonni Joned SyahrulRiki DonniDonni
Node have 2
Heap Sort 11
Heap
Rahmat
Susi
Joned
Syahrul
RikiJoned
Riki
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinJoned SyahrulRiki DonniDonniJoned Riki
Node have 2
Heap Sort 12
Not Heap
Rahmat
Susi Syahrul
Joned
Riki
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJoned RikiSyahrul JonedJoned
Node have 2
Heap Sort 13
Heap
Rahmat
Susi
Riki
SyahrulRahmat
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniSyahrul JonedRiki DonniRahmat Syahrul
Node have 2
Heap Sort 14
Not Heap
Susi
Riki
Rahmat
Syahrul
Susi
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedRiki DonniRahmat SyahrulSusi RahmatRahmat
Node have 2
Heap Sort 15
Heap
Riki Syahrul
SusiRiki
Susi
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedRiki DonniSyahrulSusi RahmatRahmatRiki Susi
Node have 2
Heap Sort 17
Heap
Susi
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatSyahrul Susi Riki
Susi
Syahrul
Susi Syahrul
Node have 2
Heap Sort 16
Not Heap
Syahrul
Riki
Susi
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRiki Susi Riki
Syahrul
Syahrul Riki
Node have 2
Heap Sort 18
Heap
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRiki
Susi
Syahrul
Susi Syahrul
Syahrul
SusiSyahrul Susi
Node have 2
Heap Sort 19
Syahrul
1 2 3 4 5 6 7 8 9 10
Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRikiSyahrulSusiSyahrul SusiSyahrul
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

Contenu connexe

Tendances (20)

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Heaps
HeapsHeaps
Heaps
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 
Shell sorting
Shell sortingShell sorting
Shell sorting
 
Heaps & priority queues
Heaps & priority queuesHeaps & priority queues
Heaps & priority queues
 
Binomial Heaps
Binomial HeapsBinomial Heaps
Binomial Heaps
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Shell sort
Shell sortShell sort
Shell sort
 
BINARY SEARCH TREE
BINARY SEARCH TREE BINARY SEARCH TREE
BINARY SEARCH TREE
 
Unit 4-booth algorithm
Unit 4-booth algorithmUnit 4-booth algorithm
Unit 4-booth algorithm
 
Shell sort
Shell sortShell sort
Shell sort
 
Digital Search Tree
Digital Search TreeDigital Search Tree
Digital Search Tree
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Quick sort
Quick sortQuick sort
Quick sort
 
Red black tree
Red black treeRed black tree
Red black tree
 
Red black tree
Red black treeRed black tree
Red black tree
 
Binomial heaps
Binomial heapsBinomial heaps
Binomial heaps
 
Heap tree
Heap treeHeap tree
Heap tree
 

En vedette

Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap SortMohammed Hussein
 
Heap sort (Monticulos)
Heap sort (Monticulos)Heap sort (Monticulos)
Heap sort (Monticulos)leidy2220
 
Cuadro comparativo-algoritmo ordenamiento heapsort
Cuadro comparativo-algoritmo ordenamiento heapsortCuadro comparativo-algoritmo ordenamiento heapsort
Cuadro comparativo-algoritmo ordenamiento heapsortWalter Navarrete Pino
 
Grafos, complejidad y redes de mundo pequeño
Grafos, complejidad y redes de mundo pequeñoGrafos, complejidad y redes de mundo pequeño
Grafos, complejidad y redes de mundo pequeñoalvaromsevilla
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeksJinTaek Seo
 
практическая работа введение данных
практическая работа введение данныхпрактическая работа введение данных
практическая работа введение данныхliza2209
 
задание
заданиезадание
заданиеliza2209
 
Effect of Solar Variability on the Helioshphere and Cosmic Rays
Effect of Solar Variability on the Helioshphere and Cosmic RaysEffect of Solar Variability on the Helioshphere and Cosmic Rays
Effect of Solar Variability on the Helioshphere and Cosmic Raysijsrd.com
 
создать банер во Flash
создать банер во Flashсоздать банер во Flash
создать банер во Flashliza2209
 
практическая работа построение диаграмм
практическая работа построение диаграммпрактическая работа построение диаграмм
практическая работа построение диаграммliza2209
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture NotesFellowBuddy.com
 

En vedette (20)

Algoritmo de ordenamiento: Heap Sort
Algoritmo de ordenamiento: Heap SortAlgoritmo de ordenamiento: Heap Sort
Algoritmo de ordenamiento: Heap Sort
 
Heap sort
Heap sortHeap sort
Heap sort
 
Heap sort
Heap sortHeap sort
Heap sort
 
Heap sort
Heap sort Heap sort
Heap sort
 
Heap sort
Heap sort Heap sort
Heap sort
 
Heap sort
Heap sortHeap sort
Heap sort
 
Heap sort
Heap sortHeap sort
Heap sort
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Heap sort (Monticulos)
Heap sort (Monticulos)Heap sort (Monticulos)
Heap sort (Monticulos)
 
Cuadro comparativo-algoritmo ordenamiento heapsort
Cuadro comparativo-algoritmo ordenamiento heapsortCuadro comparativo-algoritmo ordenamiento heapsort
Cuadro comparativo-algoritmo ordenamiento heapsort
 
CS215 - Lec 6 record index
CS215 - Lec 6  record indexCS215 - Lec 6  record index
CS215 - Lec 6 record index
 
Grafos, complejidad y redes de mundo pequeño
Grafos, complejidad y redes de mundo pequeñoGrafos, complejidad y redes de mundo pequeño
Grafos, complejidad y redes de mundo pequeño
 
05 heap 20161110_jintaeks
05 heap 20161110_jintaeks05 heap 20161110_jintaeks
05 heap 20161110_jintaeks
 
Heap Sort
Heap SortHeap Sort
Heap Sort
 
практическая работа введение данных
практическая работа введение данныхпрактическая работа введение данных
практическая работа введение данных
 
задание
заданиезадание
задание
 
Effect of Solar Variability on the Helioshphere and Cosmic Rays
Effect of Solar Variability on the Helioshphere and Cosmic RaysEffect of Solar Variability on the Helioshphere and Cosmic Rays
Effect of Solar Variability on the Helioshphere and Cosmic Rays
 
создать банер во Flash
создать банер во Flashсоздать банер во Flash
создать банер во Flash
 
практическая работа построение диаграмм
практическая работа построение диаграммпрактическая работа построение диаграмм
практическая работа построение диаграмм
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture Notes
 

Plus de 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.pdfAdam 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 NamesAdam 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 ProgrammingAdam 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 ConquerAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAdam 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 ForceAdam Mukharil Bachtiar
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAdam 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 AlgoritmaAdam Mukharil Bachtiar
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAdam Mukharil Bachtiar
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAdam Mukharil Bachtiar
 

Plus de 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
 
Clean Code - Formatting Code
Clean Code - Formatting CodeClean Code - Formatting Code
Clean Code - Formatting Code
 
Clean Code - Clean Comments
Clean Code - Clean CommentsClean Code - Clean Comments
Clean Code - Clean Comments
 
Clean Method
Clean MethodClean Method
Clean Method
 
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
 
Model Driven Software Development
Model Driven Software DevelopmentModel Driven Software Development
Model Driven Software Development
 
Scrum: How to Implement
Scrum: How to ImplementScrum: How to Implement
Scrum: How to Implement
 
Pengujian Perangkat Lunak
Pengujian Perangkat LunakPengujian Perangkat Lunak
Pengujian Perangkat Lunak
 
Data Mining Clustering
Data Mining ClusteringData Mining Clustering
Data Mining Clustering
 
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)
 
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic ProgrammingAnalisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Dynamic Programming
 
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
 
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma GreedyAnalisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Strategi Algoritma Greedy
 
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
 
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute ForceAnalisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
 
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
 
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi AsimptotikAnalisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Teorema Notasi Asimptotik
 
Analisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi AsimptotikAnalisis Algoritma - Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
 
UML dan Use Case View
UML dan Use Case ViewUML dan Use Case View
UML dan Use Case View
 

Dernier

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 

Dernier (20)

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Data Structure (Heap Sort)

  • 3. Heap Heap Tree Complete Binary Tree (CBT) Max Heap Value of node >= value of its child Min Heap Value of node <= value of its child
  • 4. Example of Heap Max Heap Min Heap 24 19 13 15 11 5 8 4 4 5 13 8 11 19 15 24 k 2k 2k+1 2k+1 2k+12k 2k 2k
  • 6. • Making of heap • Heap sort Processes in Heap
  • 7. Making of Heap • Shift down from middle node (Sum of node/2) until first node 1 2 3 4 14 11 57 5 6 3 2 1 2 3 54 6 • N = 6, Middle = N/2 = 6/2 = 3 • Reorganize on third node • Reorganize on second node • Reorganize on first node 1 2 3 4 14 11 5 7 5 6 3 2 7 3 14 11 2 53 14 2 57 14 11 7
  • 8. Heap Sort 1 a. Binary tree in Max heap state. b. “Fired” root and swap with last node. c. Subtract number of nodes with 1. d. If N > 1 then reorganize heap again. e. Repeat step b to d until node is empty (N=0) 1 2 3 54 6 1 2 3 4 14 11 5 7 5 6 3 2142 14 3 2 5 14 11 7 2
  • 9. Heap Sort 1 a.Binary tree in Max heap state. b.“Fired” root and swap with last node. c. Subtract number of nodes with 1. d.If N > 1 then reorganize heap again. e.Repeat step b to d until node is empty (N=0) 1 2 3 54 6 1 2 3 4 14 11 5 7 5 6 3 2142 14 3 2 5 14 11 7 2
  • 10. Heap Sort 2 Reorganize heap Middle = N/2 = 5/2 = 2 b. “Fired” root and swap with last node. c. Subtract number of nodes with 1. d. If N > 1 then reorganize heap again. e. Repeat step b to d until node is empty (N=0) Reorganize heap on second node. Reorganize heap on first node. 1 2 3 54 3 511 7 2 1 2 3 4 11 5 7 5 6 3 2142 14 11 27 2 2 11 27 2112 11
  • 11. Heap Sort 3 Reorganize heap Middle = N/2 = 4/2 = 2 b. “Fired” root and swap with last node. c. Subtract number of nodes with 1. d. If N > 1 then reorganize heap again. e. Repeat step b to d until node is empty (N=0) Reorganize heap on second node. Reorganize heap on first node. 1 2 3 4 3 5 2 7 1 2 3 4 5 7 5 6 3 214147 2112 11 2 7 7 2 3 2 3 2 2 72 7
  • 12. Heap Sort 4 Reorganize heap Middle = N/2 = 3/2 = 1 b. “Fired” root and swap with last node. c. Subtract number of nodes with 1. d. If N > 1 then reorganize heap again. e. Repeat step b to d until node is empty (N=0) Reorganize heap on first node. 1 2 3 5 2 3 1 2 3 4 5 7 5 6 3 21414211113 272 7 5 2 5 2 2 52 5
  • 13. Heap Sort 5 Reorganize heap Middle = N/2 = 2/2 = 1 b. “Fired” root and swap with last node. c. Subtract number of nodes with 1. d. If N > 1 then reorganize heap again. e. Repeat step b to d until node is empty (N=0) Reorganize heap on first node. 1 2 2 3 1 2 3 4 5 7 5 6 3 21414211113 277252 5 2 3 3 2 2 32 3
  • 14. Heap Sort 6 Because N = 1 then reorganize isn’t happen. b. “Fired” root c. Subtract number of nodes with 1. Because N = 0 then sorting processes is finish. 1 2 1 2 3 4 5 7 5 6 3 21414211113 277252 52332
  • 16. Node have 2 Case Example Sort these name using heap sort method in descending way. Num. Name 1 Rahmat 2 Didin 3 Ahmad 4 Joned 5 Syahrul 6 Riki 7 Arif 8 Susi 9 Donni 10 Asih
  • 17. Node have 2 Making of CBT Rahmat AhmadDidin Joned Syahrul Riki Arif Susi Donni Asih Not Heap Complete Binary Tree Rahmat Didin Ahmad Joned Syahrul Riki Arif Susi Donni Asih 1 2 3 4 5 6 7 8 9 10
  • 18. Node have 2 Heap Sort 1 1 2 3 4 5 6 7 8 9 10 Rahmat AhmadDidin Joned Syahrul Riki Arif Susi Donni Asih Heap Syahrul Asih Joned Donni Didin Asih Rahmat Ahmad Arif Rahmat Ahmad Asih Arif Donni Didin Riki Rahmat Susi Joned Syahrul
  • 19. Node have 2 Heap Sort 2 Riki Susi Not Heap SyahrulJoned Donni Didin Asih Ahmad Arif Rahmat Syahrul 1 2 3 4 5 6 7 8 9 10 Ahmad Asih Arif Donni Didin Riki Rahmat Susi Joned SyahrulAhmadSyahrul Ahmad
  • 20. Node have 2 Heap Sort 3 Riki Susi Heap Joned Donni Didin Asih Arif Rahmat SyahrulArif SyahrulRahmat Syahrul 1 2 3 4 5 6 7 8 9 10 Asih Arif Donni Didin Riki Rahmat Susi Joned SyahrulAhmadSyahrul AhmadArif SyahrulRahmat Syahrul
  • 21. Node have 2 Heap Sort 4 Riki Susi Not Heap Joned Donni Didin Asih Arif Rahmat Syahrul Joned 1 2 3 4 5 6 7 8 9 10 Asih Donni Didin Riki Susi Joned SyahrulAhmadAhmadArif Rahmat SyahrulJoned ArifArif
  • 22. Node have 2 Heap Sort 5 Riki Susi Heap Donni Didin Asih Rahmat Syahrul JonedAsih JonedDidin Joned 1 2 3 4 5 6 7 8 9 10 Asih Donni Didin Riki Susi Joned SyahrulAhmadAhmadRahmat SyahrulJoned ArifArifJonedAsih Didin Joned
  • 23. Node have 2 Heap Sort 6 Riki Susi Not Heap Donni Rahmat Syahrul Asih Didin Joned Susi 1 2 3 4 5 6 7 8 9 10 Donni Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsih Didin JonedSusi AsihAsih
  • 24. Node have 2 Heap Sort 7 Riki Heap Donni Rahmat Syahrul Didin Joned SusiDidin SusiDonni Susi 1 2 3 4 5 6 7 8 9 10 Donni Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifDidin JonedSusi AsihAsihDidin SusiDonni Susi
  • 25. Node have 2 Heap Sort 8 Riki Not Heap Rahmat SyahrulJoned Didin Donni Susi Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifJoned AsihAsihDidin Donni SusiSyahrul DidinDidin
  • 26. Node have 2 Heap Sort 9 Riki Heap Rahmat Joned Donni Susi SyahrulDonni SyahrulJoned Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifJoned AsihAsihDonni SusiSyahrul DidinDidinDonni SyahrulJoned Syahrul
  • 27. Node have 2 Heap Sort 10 Riki Not Heap Rahmat Susi Donni Joned Syahrul Riki 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinDonni Joned SyahrulRiki DonniDonni
  • 28. Node have 2 Heap Sort 11 Heap Rahmat Susi Joned Syahrul RikiJoned Riki 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinJoned SyahrulRiki DonniDonniJoned Riki
  • 29. Node have 2 Heap Sort 12 Not Heap Rahmat Susi Syahrul Joned Riki Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJoned RikiSyahrul JonedJoned
  • 30. Node have 2 Heap Sort 13 Heap Rahmat Susi Riki SyahrulRahmat Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadRahmat Syahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniSyahrul JonedRiki DonniRahmat Syahrul
  • 31. Node have 2 Heap Sort 14 Not Heap Susi Riki Rahmat Syahrul Susi 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedRiki DonniRahmat SyahrulSusi RahmatRahmat
  • 32. Node have 2 Heap Sort 15 Heap Riki Syahrul SusiRiki Susi 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedRiki DonniSyahrulSusi RahmatRahmatRiki Susi
  • 33. Node have 2 Heap Sort 17 Heap Susi Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatSyahrul Susi Riki Susi Syahrul Susi Syahrul
  • 34. Node have 2 Heap Sort 16 Not Heap Syahrul Riki Susi 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRiki Susi Riki Syahrul Syahrul Riki
  • 35. Node have 2 Heap Sort 18 Heap 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRiki Susi Syahrul Susi Syahrul Syahrul SusiSyahrul Susi
  • 36. Node have 2 Heap Sort 19 Syahrul 1 2 3 4 5 6 7 8 9 10 Riki Susi Joned SyahrulAhmadAhmadSyahrul ArifArifAsihAsihSusi DidinDidinSyahrul DonniDonniJonedDonniSyahrul RahmatRahmatRikiSyahrulSusiSyahrul SusiSyahrul
  • 37. 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