SlideShare a Scribd company logo
Adam Mukharil Bachtiar
English Class
Informatics Engineering 2011
Algorithms and Programming
Sorting
Steps of the Day
Let’s Start
Definition of
Sorting
Bubble Sort Selection
Sort
Definition of Sorting
All About Sorting
WhatisSorting
Process that arranges random data into sorted
data. Data can be sorted into ascending or
descending.
AlgorithmsofSorting
• Bubble Sort
• Selection Sort
Bubble Sort
Definition and Structures of Bubble Sort
WhatisBubbleSort
• Sorting algorithm which was inspired by
bubble soap.
• Comparing element of array (i) with next
element of it (i+1).
• If i is bigger than i+1 then swap value of
each element.
Ilustration of Bubble Sort
Array: 5 3 7 9 2 3 6 4 3 1
L. 1 3 5 7 2 3 6 4 3 1 9
L. 2 3 5 2 3 6 4 3 1 7 9
L. 3 3 2 3 5 4 3 1 6 7 9
L. 4 2 3 3 4 3 1 5 6 7 9
L. 5 2 3 3 3 1 4 5 6 7 9
L. 6 2 3 3 1 3 4 5 6 7 9
L. 7 2 3 1 3 3 4 5 6 7 9
L. 8 2 1 3 3 3 4 5 6 7 9
L. 9 1 2 3 3 3 4 5 6 7 9
Process of Bubble Sort (Ascending)
This is an array that will be sorted in Ascending way:
6 3 9 1 5
Step 1 : 6 3 9 1 5
6 3 9 1 5
6 3 1 9 5
6 1 3 9 5
1 6 3 9 5
j
j
j
j
Process of Bubble Sort (Ascending)
Step 2 : 1 6 3 9 5
1 6 3 5 9
1 6 3 5 9
1 3 6 5 9
j
j
j
Process of Bubble Sort (Ascending)
Step 3 : 1 3 6 5 9
1 3 6 5 9
1 3 5 6 9
Step 4 : 1 3 5 6 9
1 3 5 6 9
Array after sorted in ascending ways:
1 3 5 6 9
j
j
j
General Format for Bubble Sort Ascending
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Procedure BubbleSortAsc(I/O nama_var_array : nama_tipe_array,
Input N : integer)
{I.S. : array[1..N] sudah terdefinisi}
{F.S. : menghasilkan array[1..N] yang tersusun secara ascending}
Kamus:
i, j : integer
temp : tipedata
Algoritma:
for i  1 to N-1 do
for j  n downto i+1 do
if(nama_var_array[j] < nama_var_array[j-1])
then
temp  nama_var_array[j]
nama_var_array[j]  nama_var_array[j-1]
nama_var_array[j-1]  temp
endif
endfor
endfor
EndProcedure
Process of Bubble Sort (Descending)
This is an array that will be sorted in Descending way :
6 3 9 1 5
Step 1 : 6 3 9 1 5
6 3 9 1 5
6 9 3 1 5
6 9 3 1 5
6 9 3 5 1
j
j
j
j
Process of Bubble Sort (Descending)
Step 2 : 6 9 3 5 1
9 6 3 5 1
9 6 3 5 1
9 6 5 3 1
j
j
j
Process of Bubble Sort (Descending)
Step 3 : 9 6 5 3 1
9 6 5 3 1
9 6 5 3 1
Step 4 : 9 6 5 3 1
9 6 5 3 1
Array after sorted in descending ways:
9 6 5 3 1
j
j
j
General Format for Bubble Sort Descending
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Procedure BubbleSortDesc (I/O nama_var_array : nama_tipe_array,
Input N : integer)
{I.S. : array[1..N] sudah terdefinisi}
{F.S. : menghasilkan array[1..N] yang tersusun secara descending}
Kamus:
i,j : integer
temp : tipedata
Algoritma:
for i  1 to N-1 do
for j  1 to (N - i) do
if(nama_var_array[j] < nama_var_array[j+1])
then
temp  nama_var_array[j]
nama_var_array[j]  nama_var_array[j+1]
nama_var_array[j+1]  temp
endif
endfor
endfor
EndProcedure
Selection Sort
Definition and Structures of Selection Sort
WhatisSelectionSort
Sorting algorithm that arranges random data
by selecting the biggest data or the smallest
one.
MethodsinSelectionSort
• Maximum Sort
• Minimum Sort
Process of Maximum Sort (Ascending)
This is an array that will be sorted in Ascending way :
6 3 9 1 5
Step 1 : 6 3 9 1 5
6 3 9 1 5
6 3 9 1 5
6 3 9 1 5
6 3 9 1 5
6 3 5 1 9
j
j
j
jmax
max
max
max
max j
Process of Maximum Sort (Ascending)
Step 2 : 6 3 5 1 9
6 3 5 1 9
6 3 5 1 9
6 3 5 1 9
1 3 5 6 9
j
j
jmax
max
max
max j
Process of Maximum Sort (Ascending)
Step 3 : 1 3 5 6 9
1 3 5 6 9
1 3 5 6 9
1 3 5 6 9
Step 4 : 1 3 5 6 9
1 3 5 6 9
Array after sorted in descending way:
1 3 5 6 9
j
j
max
max
max
max
j
j
max
General Format for Maximum Sort Ascending
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Procedure MaximumSortAsc(I/O nama_var_array : nama_tipe_array,
Input N : integer)
{I.S. : array [1..N] sudah terdefinisi}
{F.S. : menghasilkan array [1..N] yang tersusun secara ascending}
Kamus:
i, j, max, x : integer
temp : tipedata
Algoritma:
x  n
for i  1 to N-1 do
max  1
for j  2 to x do
if(nama_var_array[j] > nama_var_array[max])
then
max  j
endif
endfor
temp  nama_var_array[max]
nama_var_array[max]  nama_var_array[j]
nama_var_array[j]  temp
x  x - 1
endfor
EndProcedure
General Format for Minimum Sort Ascending
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Procedure MinimumSortAsc(I/O nama_var_array : nama_tipe_array,
Input N : integer)
{I.S. : array[1..n] sudah terdefinisi}
{F.S. : menghasilkan array [1..n] yang tersusun secara ascending}
Kamus:
i, j, min : integer
temp : tipedata
Algoritma:
for i  1 to (N – 1) do
min  i
for j  i+1 to N do
if(nama_var_array[j] < nama_var_array[min])
then
min  j
endif
endfor
temp  nama_var_array[min]
nama_var_array[min]  nama_var_array[i]
nama_var_array[i]  temp
endfor
EndProcedure
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 2011

More Related Content

What's hot (20)

PPTX
Queue-Data Structure
Paurav Shah
 
PPTX
Interpolation search
Usr11011
 
PPTX
Quick sort
Jehat Hassan
 
PPT
4 greedy methodnew
abhinav108
 
PPTX
Unit 4 queue
Dabbal Singh Mahara
 
PPT
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
PDF
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
PPT
3.8 quicksort
Krish_ver2
 
PPTX
Hill climbing algorithm
Dr. C.V. Suresh Babu
 
PPT
Branch & bound
kannanchirayath
 
PDF
Natural Language Toolkit (NLTK), Basics
Prakash Pimpale
 
PPTX
Circular queue
Lovely Professional University
 
PPTX
A* algorithm
Komal Samdariya
 
PPTX
Queues in C++
Vineeta Garg
 
PPTX
Introduction to Machine Learning
Shahar Cohen
 
PPTX
My lectures circular queue
Senthil Kumar
 
PPTX
AI - Local Search - Hill Climbing
Andrew Ferlitsch
 
PDF
I. Hill climbing algorithm II. Steepest hill climbing algorithm
vikas dhakane
 
PPTX
Decision tree in artificial intelligence
MdAlAmin187
 
Queue-Data Structure
Paurav Shah
 
Interpolation search
Usr11011
 
Quick sort
Jehat Hassan
 
4 greedy methodnew
abhinav108
 
Unit 4 queue
Dabbal Singh Mahara
 
AI Lecture 3 (solving problems by searching)
Tajim Md. Niamat Ullah Akhund
 
9. chapter 8 np hard and np complete problems
Jyotsna Suryadevara
 
3.8 quicksort
Krish_ver2
 
Hill climbing algorithm
Dr. C.V. Suresh Babu
 
Branch & bound
kannanchirayath
 
Natural Language Toolkit (NLTK), Basics
Prakash Pimpale
 
A* algorithm
Komal Samdariya
 
Queues in C++
Vineeta Garg
 
Introduction to Machine Learning
Shahar Cohen
 
My lectures circular queue
Senthil Kumar
 
AI - Local Search - Hill Climbing
Andrew Ferlitsch
 
I. Hill climbing algorithm II. Steepest hill climbing algorithm
vikas dhakane
 
Decision tree in artificial intelligence
MdAlAmin187
 

Viewers also liked (20)

PDF
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
PPSX
Algorithm and Programming (Searching)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
PPTX
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
PDF
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
ODT
Jjj sem título 1
Juliana De Souza Pereira
 
PDF
Ground SIGINT Specialist - Afghanistan
Angelene Green
 
PDF
Mid Level Counterintelligence Support Specialist - Afghanistan
Angelene Green
 
PPTX
Linx Nòrdic 1r ESO La Salle Manlleu 2016
Annapujolo
 
PPS
Introdução ao Teste de Software
X25 Treinamento e Consultoria
 
PPTX
La pluja àcida - 1r ESO - LS Manlleu 2016
Annapujolo
 
PDF
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
PDF
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
PPTX
Pertemuan viii Sorting
Putra Andry
 
PDF
certificate in health and safety level 2
Luca De Rosa
 
PDF
Certificate for Peer Review Week '16 _ Publons
Mohamad Amin Kaviani
 
PPTX
Amyotrophic Lateral Sclerosis (ALS)
Uma Chidiebere
 
PPTX
Bucaramanga en los últimos 25 años
josenino2002
 
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Searching)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Jjj sem título 1
Juliana De Souza Pereira
 
Ground SIGINT Specialist - Afghanistan
Angelene Green
 
Mid Level Counterintelligence Support Specialist - Afghanistan
Angelene Green
 
Linx Nòrdic 1r ESO La Salle Manlleu 2016
Annapujolo
 
Introdução ao Teste de Software
X25 Treinamento e Consultoria
 
La pluja àcida - 1r ESO - LS Manlleu 2016
Annapujolo
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Pertemuan viii Sorting
Putra Andry
 
certificate in health and safety level 2
Luca De Rosa
 
Certificate for Peer Review Week '16 _ Publons
Mohamad Amin Kaviani
 
Amyotrophic Lateral Sclerosis (ALS)
Uma Chidiebere
 
Bucaramanga en los últimos 25 años
josenino2002
 
Ad

Similar to Algorithm and Programming (Sorting) (20)

PPTX
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
PPT
Sorting algorithm
Muhammad Farhan
 
DOCX
Bubble sorting lab manual
maamir farooq
 
PPT
Sorting
Shaista Qadir
 
PPTX
Sorting Data structure And Algorithm.pptx
subhanalichand514
 
PPTX
Computer sciencebubble sorting algorithm
hebahosny20060467
 
PPTX
Ppt bubble sort
prabhakar jalasutram
 
PPTX
Sorting method data structure
sunilchute1
 
PPTX
Lecture 13 data structures and algorithms
Aakash deep Singhal
 
PDF
Sorting
Kariman Karm Gabaa
 
PPTX
Basic Sorting algorithms csharp
Micheal Ogundero
 
PPTX
enhancement of sorting algorithm
Rana assad ali
 
PPTX
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
ArjayBalberan1
 
PPT
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PDF
Selection sort
Abdelrahman Saleh
 
PPTX
Unit 7 sorting
Dabbal Singh Mahara
 
PPTX
Selection Sort On C++.ppt.pptx
MuneebUrRehman643659
 
PPT
COMPUTER PROGRAMMING UNIT 1 Lecture 5
Vishal Patil
 
PPTX
DSA_chapter and chapter 3 _03_Sorting Algorithms.pptx
tahliildhoore54
 
PPT
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
Sorting algorithm
Muhammad Farhan
 
Bubble sorting lab manual
maamir farooq
 
Sorting
Shaista Qadir
 
Sorting Data structure And Algorithm.pptx
subhanalichand514
 
Computer sciencebubble sorting algorithm
hebahosny20060467
 
Ppt bubble sort
prabhakar jalasutram
 
Sorting method data structure
sunilchute1
 
Lecture 13 data structures and algorithms
Aakash deep Singhal
 
Basic Sorting algorithms csharp
Micheal Ogundero
 
enhancement of sorting algorithm
Rana assad ali
 
MYSQL DATABASE MYSQL DATABASE MYSQL DATABASE BUBLESORT.pptx
ArjayBalberan1
 
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Selection sort
Abdelrahman Saleh
 
Unit 7 sorting
Dabbal Singh Mahara
 
Selection Sort On C++.ppt.pptx
MuneebUrRehman643659
 
COMPUTER PROGRAMMING UNIT 1 Lecture 5
Vishal Patil
 
DSA_chapter and chapter 3 _03_Sorting Algorithms.pptx
tahliildhoore54
 
358 33 powerpoint-slides_14-sorting_chapter-14
sumitbardhan
 
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 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)

PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Import Data Form Excel to Tally Services
Tally xperts
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 

Algorithm and Programming (Sorting)

  • 1. Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Sorting
  • 2. Steps of the Day Let’s Start Definition of Sorting Bubble Sort Selection Sort
  • 4. WhatisSorting Process that arranges random data into sorted data. Data can be sorted into ascending or descending.
  • 6. Bubble Sort Definition and Structures of Bubble Sort
  • 7. WhatisBubbleSort • Sorting algorithm which was inspired by bubble soap. • Comparing element of array (i) with next element of it (i+1). • If i is bigger than i+1 then swap value of each element.
  • 8. Ilustration of Bubble Sort Array: 5 3 7 9 2 3 6 4 3 1 L. 1 3 5 7 2 3 6 4 3 1 9 L. 2 3 5 2 3 6 4 3 1 7 9 L. 3 3 2 3 5 4 3 1 6 7 9 L. 4 2 3 3 4 3 1 5 6 7 9 L. 5 2 3 3 3 1 4 5 6 7 9 L. 6 2 3 3 1 3 4 5 6 7 9 L. 7 2 3 1 3 3 4 5 6 7 9 L. 8 2 1 3 3 3 4 5 6 7 9 L. 9 1 2 3 3 3 4 5 6 7 9
  • 9. Process of Bubble Sort (Ascending) This is an array that will be sorted in Ascending way: 6 3 9 1 5 Step 1 : 6 3 9 1 5 6 3 9 1 5 6 3 1 9 5 6 1 3 9 5 1 6 3 9 5 j j j j
  • 10. Process of Bubble Sort (Ascending) Step 2 : 1 6 3 9 5 1 6 3 5 9 1 6 3 5 9 1 3 6 5 9 j j j
  • 11. Process of Bubble Sort (Ascending) Step 3 : 1 3 6 5 9 1 3 6 5 9 1 3 5 6 9 Step 4 : 1 3 5 6 9 1 3 5 6 9 Array after sorted in ascending ways: 1 3 5 6 9 j j j
  • 12. General Format for Bubble Sort Ascending 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Procedure BubbleSortAsc(I/O nama_var_array : nama_tipe_array, Input N : integer) {I.S. : array[1..N] sudah terdefinisi} {F.S. : menghasilkan array[1..N] yang tersusun secara ascending} Kamus: i, j : integer temp : tipedata Algoritma: for i  1 to N-1 do for j  n downto i+1 do if(nama_var_array[j] < nama_var_array[j-1]) then temp  nama_var_array[j] nama_var_array[j]  nama_var_array[j-1] nama_var_array[j-1]  temp endif endfor endfor EndProcedure
  • 13. Process of Bubble Sort (Descending) This is an array that will be sorted in Descending way : 6 3 9 1 5 Step 1 : 6 3 9 1 5 6 3 9 1 5 6 9 3 1 5 6 9 3 1 5 6 9 3 5 1 j j j j
  • 14. Process of Bubble Sort (Descending) Step 2 : 6 9 3 5 1 9 6 3 5 1 9 6 3 5 1 9 6 5 3 1 j j j
  • 15. Process of Bubble Sort (Descending) Step 3 : 9 6 5 3 1 9 6 5 3 1 9 6 5 3 1 Step 4 : 9 6 5 3 1 9 6 5 3 1 Array after sorted in descending ways: 9 6 5 3 1 j j j
  • 16. General Format for Bubble Sort Descending 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Procedure BubbleSortDesc (I/O nama_var_array : nama_tipe_array, Input N : integer) {I.S. : array[1..N] sudah terdefinisi} {F.S. : menghasilkan array[1..N] yang tersusun secara descending} Kamus: i,j : integer temp : tipedata Algoritma: for i  1 to N-1 do for j  1 to (N - i) do if(nama_var_array[j] < nama_var_array[j+1]) then temp  nama_var_array[j] nama_var_array[j]  nama_var_array[j+1] nama_var_array[j+1]  temp endif endfor endfor EndProcedure
  • 17. Selection Sort Definition and Structures of Selection Sort
  • 18. WhatisSelectionSort Sorting algorithm that arranges random data by selecting the biggest data or the smallest one.
  • 20. Process of Maximum Sort (Ascending) This is an array that will be sorted in Ascending way : 6 3 9 1 5 Step 1 : 6 3 9 1 5 6 3 9 1 5 6 3 9 1 5 6 3 9 1 5 6 3 9 1 5 6 3 5 1 9 j j j jmax max max max max j
  • 21. Process of Maximum Sort (Ascending) Step 2 : 6 3 5 1 9 6 3 5 1 9 6 3 5 1 9 6 3 5 1 9 1 3 5 6 9 j j jmax max max max j
  • 22. Process of Maximum Sort (Ascending) Step 3 : 1 3 5 6 9 1 3 5 6 9 1 3 5 6 9 1 3 5 6 9 Step 4 : 1 3 5 6 9 1 3 5 6 9 Array after sorted in descending way: 1 3 5 6 9 j j max max max max j j max
  • 23. General Format for Maximum Sort Ascending 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Procedure MaximumSortAsc(I/O nama_var_array : nama_tipe_array, Input N : integer) {I.S. : array [1..N] sudah terdefinisi} {F.S. : menghasilkan array [1..N] yang tersusun secara ascending} Kamus: i, j, max, x : integer temp : tipedata Algoritma: x  n for i  1 to N-1 do max  1 for j  2 to x do if(nama_var_array[j] > nama_var_array[max]) then max  j endif endfor temp  nama_var_array[max] nama_var_array[max]  nama_var_array[j] nama_var_array[j]  temp x  x - 1 endfor EndProcedure
  • 24. General Format for Minimum Sort Ascending 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Procedure MinimumSortAsc(I/O nama_var_array : nama_tipe_array, Input N : integer) {I.S. : array[1..n] sudah terdefinisi} {F.S. : menghasilkan array [1..n] yang tersusun secara ascending} Kamus: i, j, min : integer temp : tipedata Algoritma: for i  1 to (N – 1) do min  i for j  i+1 to N do if(nama_var_array[j] < nama_var_array[min]) then min  j endif endfor temp  nama_var_array[min] nama_var_array[min]  nama_var_array[i] nama_var_array[i]  temp endfor EndProcedure
  • 25. 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 2011