SlideShare a Scribd company logo
Adam Mukharil Bachtiar
English Class
Informatics Engineering 2011
Algorithms and Programming
Searching
Steps of the Day
Let’s Start
Definition of
Searching
Sequential
Search
Binary
Search
Definition of Searching
All About Searching
WhatisSearching
Process that search the value in group of data.
This process can produce FOUND or NOT
FOUND value.
AlgorithmsofSorting
• Sequential search / Linear search
• Binary search
Sequential Search
Definition and Structures of Sequential Search
WhatisSequentialSearch
• Trace group of data one by one.
• Start the process from the first data.
• If the data was found in group then stop
the searching but if not, search until the
last data in grup.
MethodsinSequentialSearch
• Without boolean
 Without sentinel
 Use sentinel
• Use boolean
Ilustration of Seq. Search Without Sentinel
Given an array to be processed:
Number
Data that want to be sought : 9
• Number[1] = 9?
• Number[2] = 9?
• Number[3] = 9?
Result: 9 is found in number[3]
5 1 9 4 2
[1] [2] [3] [4] [5]
i  i + 1
i  i + 1
i (STOP SEARCH)
Sequential Search Without Sentinel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Procedure SeqSearchTanpaSentinel (Input nama_array:tipe_array)
{I.S. : elemen array [1..maks_array] sudah terdefinisi}
{F.S. : menampilkan hasil pencarian (ditemukan/tidak)}
Kamus:
i : integer
data_cari : tipedata
Algoritma:
input(data_cari)
i  1
while(nama_array [i] ≠ data_cari) and (i < maks_array) do
i  i + 1
endwhile
if (nama_array[i] = data_cari)
then
output(data_cari,’ ditemukan pada indeks ke-’,i)
else
output(data_cari,’ tidak ditemukan’)
endif
EndProcedure
SequentialSearchUseSentinel
• Place the data that want to be sought in
sentinel.
• Sentinel is additional index that was placed in
max array + 1.
• If the data is found in sentinel that means the
result is data is not found and vice versa.
Ilustration of Seq. Search Use Sentinel
Data that was sought: 9
Number
Result: Data was found in Number[3]
Data that was sought: 10
Number
Result: Data was not found
5 1 9 4 2 9
[1] [2] [3] [4] [5] [6]
sentinel
5 1 9 4 2 10
[1] [2] [3] [4] [5] [6]
sentinel
Sequential Search Use Sentinel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Procedure SeqSearchSentinel (Input nama_array:tipe_array)
{I.S. : elemen array [1..maks_array] sudah terdefinisi}
{F.S. : menampilkan hasil pencarian (ditemukan/tidak)}
Kamus:
i : integer
data_cari : tipedata
Algoritma:
input(data_cari)
i  1
nama_array(maks_array + 1)  data_cari
while (nama_array [i] ≠ data_cari) do
i  i + 1
endwhile
if (i < maks_array+1)
then
output(data_cari,’ ditemukan pada indeks ke-’,i)
else
output(data_cari,’ tidak ditemukan’)
endif
EndProcedure
SequentialSearchUseBoolean
• Its searching process is similar with another
sequential search method.
• Involves one boolean variable.
Ilustration of Seq. Search Use Boolean
Given an array to be processed:
Number
Data that want to be sought : 9
• Number[1] = 9?
• Number[2] = 9?
• Number[3] = 9?
Result: 9 is found in number[3]
5 1 9 4 2
[1] [2] [3] [4] [5]
FOUND  FALSE
FOUND  FALSE
FOUND  TRUE (STOP SEARCH)
Sequential Search Use Sentinel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Procedure SeqSearchBoolean (Input nama_array:tipe_array)
{I.S. : elemen array [1..maks_array] sudah terdefinisi}
{F.S. : menampilkan data yg dicari ditemukan atau tidak ditemukan}
Kamus:
i : integer
ketemu : boolean
data_cari : tipedata
Algoritma:
input(data_cari)
i  1
ketemu  false
while (not ketemu) and (i ≤ maks_array) do
if(nama_var_array(i) = data_cari)
then
ketemu  true
else
i  i + 1
endif
endwhile
if (ketemu)
then
output(data_cari,’ ditemukan pada indeks ke-’,i)
else
output(data_cari,’ tidak ditemukan’)
endif
EndProcedure
Binary Search
Definition and Structures of Binary Search
WhatisBinarySearch
• Searching algorithm that divide group of data into
two parts (left and right).
• First, check data in the middle. If same with the
data that was sought then data is found. If not then
continue searching process to left or right (based
on condition).
• Group of data must be sorted before the searching
process.
Data that was sought: 7
Number
Result: ?
CaseExampleofBinarySearch
3 7 12 15 29
[1] [2] [3] [4] [5]
Case Example of Binary Search
Data that was sought: 7
Number
Result: ?
3 7 12 15 29
[1] [2] [3] [4] [5]
Case Example of Binary Search
Step 1 : Divide array into 2 parts. Count the middle
position (k) of array to start searching
k = (Ia + Ib) div 2
= (1 + 5) div 2
= 3
la : lower bound (for index)
lb : upper bound (for index)
3 7 12 15 29
[1] [2] [3] [4] [5]
Ia k Ib
Left Side Right Side
Case Example of Binary Search
Step 2 :
• check data in k. If it’s same with data that was sought then
stop search and data is found.
• If it’s not then check whether data was bigger or smaller than
data in k.
• If it’s bigger one then continue searching to right side and la
= k+1. if it’s smaller one then continue searching to the left
side and lb = k-1 (data wa sorted in ascending way).
3 7
1 2
Ia Ib
Case Example of Binary Search
Step 3 : repeat step 1 until step 2 until data is found or until
la>lb then stop searching.
Result : 7 is found in Number[2] and in the third looping.
3 7
1 2
Ia Ib
k
Left Side Right Side
Binary Search
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Procedure BinarySearch (Input nama_array : tipe_array)
{I.S. : elemen array yang terurut secara ascending sudah terdefinisi}
{F.S. : menampilkan data yg dicari ditemukan atau tidak ditemukan}
Kamus:
Ia, Ib, k : integer
ketemu : boolean
data_cari : tipedata
Algoritma:
input(data_cari)
Ia  1
Ib  maks_array
ketemu  false
while (not ketemu) and (Ia ≤ Ib) do
k  (Ia + Ib) div 2
if (nama_var_array[k] = data_cari)
then
ketemu  true
else
if (nama_var_array[k] < data_cari)
then
Ia  k + 1
else
Ib  k – 1
endif
endif
endwhile
Binary Search
27
28
29
30
31
32
33
if (ketemu)
then
output(data_cari,’ ditemukan pada indeks ke-’,k)
else
output(data_cari,’ tidak ditemukan’)
endif
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)

Power Point \ PPT - Memori Eksternal
Power Point \ PPT - Memori EksternalPower Point \ PPT - Memori Eksternal
Power Point \ PPT - Memori Eksternal
Indri Sukmawati Rahayu
 
Modul praktikum 11 hashing table
Modul praktikum 11 hashing tableModul praktikum 11 hashing table
Modul praktikum 11 hashing table
rahmi wahyuni
 
Kriptografi Modern
Kriptografi ModernKriptografi Modern
Kriptografi Modern
Andini Putri
 
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
4.1 Operasi Dasar Singly Linked List  1 (primitive list)4.1 Operasi Dasar Singly Linked List  1 (primitive list)
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
Kelinci Coklat
 
Data annotation validation (ASP.net)
Data annotation validation (ASP.net)Data annotation validation (ASP.net)
Data annotation validation (ASP.net)
Jyotasana Bharti
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
kalyanineve
 
NLTK
NLTKNLTK
NLTK
Girish Khanzode
 
program pencarian data dengan bahasa C
program pencarian data dengan bahasa Cprogram pencarian data dengan bahasa C
program pencarian data dengan bahasa C
kir yy
 
Data Mining - Naive Bayes
Data Mining - Naive BayesData Mining - Naive Bayes
Data Mining - Naive Bayes
dedidarwis
 
Kumpulan program-pascal
Kumpulan program-pascalKumpulan program-pascal
Kumpulan program-pascal
Hana Zainab Mukarromah
 
Keamanan Jaringan Komputer
Keamanan Jaringan KomputerKeamanan Jaringan Komputer
Keamanan Jaringan Komputer
A Sisdianto Sumarna
 
Complexity analysis - The Big O Notation
Complexity analysis - The Big O NotationComplexity analysis - The Big O Notation
Complexity analysis - The Big O Notation
Jawad Khan
 
Comandos de word utsv
Comandos de word utsvComandos de word utsv
Comandos de word utsv
susilux
 
Pertemuan-12-normalisasi.pptx
Pertemuan-12-normalisasi.pptxPertemuan-12-normalisasi.pptx
Pertemuan-12-normalisasi.pptx
nurnur469094
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
Hossam Hassan
 
7. Queue (Struktur Data)
7. Queue (Struktur Data)7. Queue (Struktur Data)
7. Queue (Struktur Data)
Kelinci Coklat
 
Interaksi manusia dan komputer
Interaksi manusia dan komputerInteraksi manusia dan komputer
Interaksi manusia dan komputer
Miftahul Khair N
 
Manajemen file windows
Manajemen file windowsManajemen file windows
Manajemen file windows
dimas wahab
 
Modul praktikum 11 hashing table
Modul praktikum 11 hashing tableModul praktikum 11 hashing table
Modul praktikum 11 hashing table
rahmi wahyuni
 
Kriptografi Modern
Kriptografi ModernKriptografi Modern
Kriptografi Modern
Andini Putri
 
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
4.1 Operasi Dasar Singly Linked List  1 (primitive list)4.1 Operasi Dasar Singly Linked List  1 (primitive list)
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
Kelinci Coklat
 
Data annotation validation (ASP.net)
Data annotation validation (ASP.net)Data annotation validation (ASP.net)
Data annotation validation (ASP.net)
Jyotasana Bharti
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
kalyanineve
 
program pencarian data dengan bahasa C
program pencarian data dengan bahasa Cprogram pencarian data dengan bahasa C
program pencarian data dengan bahasa C
kir yy
 
Data Mining - Naive Bayes
Data Mining - Naive BayesData Mining - Naive Bayes
Data Mining - Naive Bayes
dedidarwis
 
Complexity analysis - The Big O Notation
Complexity analysis - The Big O NotationComplexity analysis - The Big O Notation
Complexity analysis - The Big O Notation
Jawad Khan
 
Comandos de word utsv
Comandos de word utsvComandos de word utsv
Comandos de word utsv
susilux
 
Pertemuan-12-normalisasi.pptx
Pertemuan-12-normalisasi.pptxPertemuan-12-normalisasi.pptx
Pertemuan-12-normalisasi.pptx
nurnur469094
 
Search algorithms master
Search algorithms masterSearch algorithms master
Search algorithms master
Hossam Hassan
 
7. Queue (Struktur Data)
7. Queue (Struktur Data)7. Queue (Struktur Data)
7. Queue (Struktur Data)
Kelinci Coklat
 
Interaksi manusia dan komputer
Interaksi manusia dan komputerInteraksi manusia dan komputer
Interaksi manusia dan komputer
Miftahul Khair N
 
Manajemen file windows
Manajemen file windowsManajemen file windows
Manajemen file windows
dimas wahab
 

Viewers also liked (20)

Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Record)
Algorithm and Programming (Record)Algorithm and Programming (Record)
Algorithm and Programming (Record)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Ibm quantum computing
Ibm quantum computingIbm quantum computing
Ibm quantum computing
Francisco J. Gálvez Ramírez
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Präsentation linkedin
Präsentation linkedinPräsentation linkedin
Präsentation linkedin
Dieter Stempel
 
Destrucció hàbitats - 1r ESO LS Manlleu 2016
Destrucció hàbitats - 1r ESO LS Manlleu 2016Destrucció hàbitats - 1r ESO LS Manlleu 2016
Destrucció hàbitats - 1r ESO LS Manlleu 2016
Annapujolo
 
Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02
Magda Elswesy
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
El llop 1r ESO La Salle Manlleu 2016
El llop 1r ESO La Salle Manlleu 2016El llop 1r ESO La Salle Manlleu 2016
El llop 1r ESO La Salle Manlleu 2016
Annapujolo
 
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
Annapujolo
 
Repayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZRepayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZ
Angelene Green
 
Introduction to Quantum Computing & Quantum Information Theory
Introduction to Quantum Computing & Quantum Information TheoryIntroduction to Quantum Computing & Quantum Information Theory
Introduction to Quantum Computing & Quantum Information Theory
Rahul Mee
 
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Paulraj Pappaiah
 
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢIĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
Luanvanyhoc.com-Zalo 0927.007.596
 
Data Structure (Double Linked List)
Data Structure (Double Linked List)Data Structure (Double Linked List)
Data Structure (Double Linked List)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
Adam Mukharil Bachtiar
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
Adam Mukharil Bachtiar
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Präsentation linkedin
Präsentation linkedinPräsentation linkedin
Präsentation linkedin
Dieter Stempel
 
Destrucció hàbitats - 1r ESO LS Manlleu 2016
Destrucció hàbitats - 1r ESO LS Manlleu 2016Destrucció hàbitats - 1r ESO LS Manlleu 2016
Destrucció hàbitats - 1r ESO LS Manlleu 2016
Annapujolo
 
Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02
Magda Elswesy
 
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Algorithm and Programming (Introduction of dev pascal, data type, value, and ...
Adam Mukharil Bachtiar
 
El llop 1r ESO La Salle Manlleu 2016
El llop 1r ESO La Salle Manlleu 2016El llop 1r ESO La Salle Manlleu 2016
El llop 1r ESO La Salle Manlleu 2016
Annapujolo
 
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
L'afebliment de la capa d'ozó - 1r ESO LS Manlleu 2016
Annapujolo
 
Repayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZRepayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZ
Angelene Green
 
Introduction to Quantum Computing & Quantum Information Theory
Introduction to Quantum Computing & Quantum Information TheoryIntroduction to Quantum Computing & Quantum Information Theory
Introduction to Quantum Computing & Quantum Information Theory
Rahul Mee
 
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Migrating IBM Cloud Orchestrator environment from v2.4.0.2 to v2.5.0.1
Paulraj Pappaiah
 
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢIĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
ĐÁNH GIÁ KẾT QUẢ VÁ NHĨ BẰNG KỸ THUẬT ĐẶT MẢNH GHÉP TRÊN-DƯỚI LỚP SỢI
Luanvanyhoc.com-Zalo 0927.007.596
 
Ad

Similar to Algorithm and Programming (Searching) (20)

Chapter 4: basic search algorithms data structure
Chapter 4: basic search algorithms data structureChapter 4: basic search algorithms data structure
Chapter 4: basic search algorithms data structure
Mahmoud Alfarra
 
Chapter 2. data structure and algorithm
Chapter  2. data structure and algorithmChapter  2. data structure and algorithm
Chapter 2. data structure and algorithm
SolomonEndalu
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
Trupti Agrawal
 
Unit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTINGUnit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTING
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Chapter #3 (Searchinmmmg ALgorithm).pptx
Chapter #3 (Searchinmmmg ALgorithm).pptxChapter #3 (Searchinmmmg ALgorithm).pptx
Chapter #3 (Searchinmmmg ALgorithm).pptx
hekmatyarzahir44
 
Ocw chp6 2searchbinary
Ocw chp6 2searchbinaryOcw chp6 2searchbinary
Ocw chp6 2searchbinary
Prashant Rai
 
06-search-ar121r11111ay-1-LinearBinary.ppt
06-search-ar121r11111ay-1-LinearBinary.ppt06-search-ar121r11111ay-1-LinearBinary.ppt
06-search-ar121r11111ay-1-LinearBinary.ppt
KamalakarHegde
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
Trupti Agrawal
 
searching
searchingsearching
searching
A. S. M. Shafi
 
Searching
SearchingSearching
Searching
A. S. M. Shafi
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
Binary search Algorithm
Binary search AlgorithmBinary search Algorithm
Binary search Algorithm
FazalRehman79
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
chouguleamruta24
 
Data Structures Unit 2 FINAL presentation.pptx
Data Structures   Unit 2 FINAL presentation.pptxData Structures   Unit 2 FINAL presentation.pptx
Data Structures Unit 2 FINAL presentation.pptx
dilipd20
 
Chapter 2 Sorting and Searching .pptx.soft
Chapter 2 Sorting and Searching  .pptx.softChapter 2 Sorting and Searching  .pptx.soft
Chapter 2 Sorting and Searching .pptx.soft
kuruabeje7
 
Lecture_Oct26.pptx
Lecture_Oct26.pptxLecture_Oct26.pptx
Lecture_Oct26.pptx
SylrizcinMarieManzo3
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
AndiNurkholis1
 
Searching.ppt
Searching.pptSearching.ppt
Searching.ppt
SpammemeLmao
 
Searching Algorithms - Foundations of Algorithms
Searching Algorithms - Foundations of AlgorithmsSearching Algorithms - Foundations of Algorithms
Searching Algorithms - Foundations of Algorithms
ssusere05275
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
nikunjandy
 
Chapter 4: basic search algorithms data structure
Chapter 4: basic search algorithms data structureChapter 4: basic search algorithms data structure
Chapter 4: basic search algorithms data structure
Mahmoud Alfarra
 
Chapter 2. data structure and algorithm
Chapter  2. data structure and algorithmChapter  2. data structure and algorithm
Chapter 2. data structure and algorithm
SolomonEndalu
 
Chapter #3 (Searchinmmmg ALgorithm).pptx
Chapter #3 (Searchinmmmg ALgorithm).pptxChapter #3 (Searchinmmmg ALgorithm).pptx
Chapter #3 (Searchinmmmg ALgorithm).pptx
hekmatyarzahir44
 
Ocw chp6 2searchbinary
Ocw chp6 2searchbinaryOcw chp6 2searchbinary
Ocw chp6 2searchbinary
Prashant Rai
 
06-search-ar121r11111ay-1-LinearBinary.ppt
06-search-ar121r11111ay-1-LinearBinary.ppt06-search-ar121r11111ay-1-LinearBinary.ppt
06-search-ar121r11111ay-1-LinearBinary.ppt
KamalakarHegde
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
Binary search Algorithm
Binary search AlgorithmBinary search Algorithm
Binary search Algorithm
FazalRehman79
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
chouguleamruta24
 
Data Structures Unit 2 FINAL presentation.pptx
Data Structures   Unit 2 FINAL presentation.pptxData Structures   Unit 2 FINAL presentation.pptx
Data Structures Unit 2 FINAL presentation.pptx
dilipd20
 
Chapter 2 Sorting and Searching .pptx.soft
Chapter 2 Sorting and Searching  .pptx.softChapter 2 Sorting and Searching  .pptx.soft
Chapter 2 Sorting and Searching .pptx.soft
kuruabeje7
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
AndiNurkholis1
 
Searching Algorithms - Foundations of Algorithms
Searching Algorithms - Foundations of AlgorithmsSearching Algorithms - Foundations of Algorithms
Searching Algorithms - Foundations of Algorithms
ssusere05275
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
nikunjandy
 
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)

The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right WayMigrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Maximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdfMaximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdf
Elena Mia
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Bonk coin airdrop_ Everything You Need to Know.pdf
Bonk coin airdrop_ Everything You Need to Know.pdfBonk coin airdrop_ Everything You Need to Know.pdf
Bonk coin airdrop_ Everything You Need to Know.pdf
Herond Labs
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025FME as an Orchestration Tool - Peak of Data & AI 2025
FME as an Orchestration Tool - Peak of Data & AI 2025
Safe Software
 
COBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM CertificateCOBOL Programming with VSCode - IBM Certificate
COBOL Programming with VSCode - IBM Certificate
VICTOR MAESTRE RAMIREZ
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Automating Map Production With FME and Python
Automating Map Production With FME and PythonAutomating Map Production With FME and Python
Automating Map Production With FME and Python
Safe Software
 
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
Maintaining + Optimizing Database Health: Vendors, Orchestrations, Enrichment...
BradBedford3
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptxwAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines OperationsHow Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Maximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdfMaximizing Business Value with AWS Consulting Services.pdf
Maximizing Business Value with AWS Consulting Services.pdf
Elena Mia
 
Revolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management SoftwareRevolutionize Your Insurance Workflow with Claims Management Software
Revolutionize Your Insurance Workflow with Claims Management Software
Insurance Tech Services
 
Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3Software Engineering Process, Notation & Tools Introduction - Part 3
Software Engineering Process, Notation & Tools Introduction - Part 3
Gaurav Sharma
 
Who will create the languages of the future?
Who will create the languages of the future?Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Bonk coin airdrop_ Everything You Need to Know.pdf
Bonk coin airdrop_ Everything You Need to Know.pdfBonk coin airdrop_ Everything You Need to Know.pdf
Bonk coin airdrop_ Everything You Need to Know.pdf
Herond Labs
 
dp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdfdp-700 exam questions sample docume .pdf
dp-700 exam questions sample docume .pdf
pravkumarbiz
 
14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework14 Years of Developing nCine - An Open Source 2D Game Framework
14 Years of Developing nCine - An Open Source 2D Game Framework
Angelo Theodorou
 
FME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable InsightsFME for Climate Data: Turning Big Data into Actionable Insights
FME for Climate Data: Turning Big Data into Actionable Insights
Safe Software
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free DownloadWondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
IBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - IntroductionIBM Rational Unified Process For Software Engineering - Introduction
IBM Rational Unified Process For Software Engineering - Introduction
Gaurav Sharma
 

Algorithm and Programming (Searching)

  • 1. Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Searching
  • 2. Steps of the Day Let’s Start Definition of Searching Sequential Search Binary Search
  • 3. Definition of Searching All About Searching
  • 4. WhatisSearching Process that search the value in group of data. This process can produce FOUND or NOT FOUND value.
  • 5. AlgorithmsofSorting • Sequential search / Linear search • Binary search
  • 6. Sequential Search Definition and Structures of Sequential Search
  • 7. WhatisSequentialSearch • Trace group of data one by one. • Start the process from the first data. • If the data was found in group then stop the searching but if not, search until the last data in grup.
  • 8. MethodsinSequentialSearch • Without boolean  Without sentinel  Use sentinel • Use boolean
  • 9. Ilustration of Seq. Search Without Sentinel Given an array to be processed: Number Data that want to be sought : 9 • Number[1] = 9? • Number[2] = 9? • Number[3] = 9? Result: 9 is found in number[3] 5 1 9 4 2 [1] [2] [3] [4] [5] i  i + 1 i  i + 1 i (STOP SEARCH)
  • 10. Sequential Search Without Sentinel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Procedure SeqSearchTanpaSentinel (Input nama_array:tipe_array) {I.S. : elemen array [1..maks_array] sudah terdefinisi} {F.S. : menampilkan hasil pencarian (ditemukan/tidak)} Kamus: i : integer data_cari : tipedata Algoritma: input(data_cari) i  1 while(nama_array [i] ≠ data_cari) and (i < maks_array) do i  i + 1 endwhile if (nama_array[i] = data_cari) then output(data_cari,’ ditemukan pada indeks ke-’,i) else output(data_cari,’ tidak ditemukan’) endif EndProcedure
  • 11. SequentialSearchUseSentinel • Place the data that want to be sought in sentinel. • Sentinel is additional index that was placed in max array + 1. • If the data is found in sentinel that means the result is data is not found and vice versa.
  • 12. Ilustration of Seq. Search Use Sentinel Data that was sought: 9 Number Result: Data was found in Number[3] Data that was sought: 10 Number Result: Data was not found 5 1 9 4 2 9 [1] [2] [3] [4] [5] [6] sentinel 5 1 9 4 2 10 [1] [2] [3] [4] [5] [6] sentinel
  • 13. Sequential Search Use Sentinel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Procedure SeqSearchSentinel (Input nama_array:tipe_array) {I.S. : elemen array [1..maks_array] sudah terdefinisi} {F.S. : menampilkan hasil pencarian (ditemukan/tidak)} Kamus: i : integer data_cari : tipedata Algoritma: input(data_cari) i  1 nama_array(maks_array + 1)  data_cari while (nama_array [i] ≠ data_cari) do i  i + 1 endwhile if (i < maks_array+1) then output(data_cari,’ ditemukan pada indeks ke-’,i) else output(data_cari,’ tidak ditemukan’) endif EndProcedure
  • 14. SequentialSearchUseBoolean • Its searching process is similar with another sequential search method. • Involves one boolean variable.
  • 15. Ilustration of Seq. Search Use Boolean Given an array to be processed: Number Data that want to be sought : 9 • Number[1] = 9? • Number[2] = 9? • Number[3] = 9? Result: 9 is found in number[3] 5 1 9 4 2 [1] [2] [3] [4] [5] FOUND  FALSE FOUND  FALSE FOUND  TRUE (STOP SEARCH)
  • 16. Sequential Search Use Sentinel 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Procedure SeqSearchBoolean (Input nama_array:tipe_array) {I.S. : elemen array [1..maks_array] sudah terdefinisi} {F.S. : menampilkan data yg dicari ditemukan atau tidak ditemukan} Kamus: i : integer ketemu : boolean data_cari : tipedata Algoritma: input(data_cari) i  1 ketemu  false while (not ketemu) and (i ≤ maks_array) do if(nama_var_array(i) = data_cari) then ketemu  true else i  i + 1 endif endwhile if (ketemu) then output(data_cari,’ ditemukan pada indeks ke-’,i) else output(data_cari,’ tidak ditemukan’) endif EndProcedure
  • 17. Binary Search Definition and Structures of Binary Search
  • 18. WhatisBinarySearch • Searching algorithm that divide group of data into two parts (left and right). • First, check data in the middle. If same with the data that was sought then data is found. If not then continue searching process to left or right (based on condition). • Group of data must be sorted before the searching process.
  • 19. Data that was sought: 7 Number Result: ? CaseExampleofBinarySearch 3 7 12 15 29 [1] [2] [3] [4] [5]
  • 20. Case Example of Binary Search Data that was sought: 7 Number Result: ? 3 7 12 15 29 [1] [2] [3] [4] [5]
  • 21. Case Example of Binary Search Step 1 : Divide array into 2 parts. Count the middle position (k) of array to start searching k = (Ia + Ib) div 2 = (1 + 5) div 2 = 3 la : lower bound (for index) lb : upper bound (for index) 3 7 12 15 29 [1] [2] [3] [4] [5] Ia k Ib Left Side Right Side
  • 22. Case Example of Binary Search Step 2 : • check data in k. If it’s same with data that was sought then stop search and data is found. • If it’s not then check whether data was bigger or smaller than data in k. • If it’s bigger one then continue searching to right side and la = k+1. if it’s smaller one then continue searching to the left side and lb = k-1 (data wa sorted in ascending way). 3 7 1 2 Ia Ib
  • 23. Case Example of Binary Search Step 3 : repeat step 1 until step 2 until data is found or until la>lb then stop searching. Result : 7 is found in Number[2] and in the third looping. 3 7 1 2 Ia Ib k Left Side Right Side
  • 24. Binary Search 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Procedure BinarySearch (Input nama_array : tipe_array) {I.S. : elemen array yang terurut secara ascending sudah terdefinisi} {F.S. : menampilkan data yg dicari ditemukan atau tidak ditemukan} Kamus: Ia, Ib, k : integer ketemu : boolean data_cari : tipedata Algoritma: input(data_cari) Ia  1 Ib  maks_array ketemu  false while (not ketemu) and (Ia ≤ Ib) do k  (Ia + Ib) div 2 if (nama_var_array[k] = data_cari) then ketemu  true else if (nama_var_array[k] < data_cari) then Ia  k + 1 else Ib  k – 1 endif endif endwhile
  • 25. Binary Search 27 28 29 30 31 32 33 if (ketemu) then output(data_cari,’ ditemukan pada indeks ke-’,k) else output(data_cari,’ tidak ditemukan’) endif EndProcedure
  • 26. 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