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

Context Free Grammar 1 - Materi 6 - TBO
Context Free Grammar 1 - Materi 6 - TBOContext Free Grammar 1 - Materi 6 - TBO
Context Free Grammar 1 - Materi 6 - TBO
ahmad haidaroh
 
Materi 7 Context Free Grammar
Materi 7   Context Free Grammar Materi 7   Context Free Grammar
Materi 7 Context Free Grammar
ahmad haidaroh
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
montazur420
 
Unit 5 internal sorting &amp; files
Unit 5  internal sorting &amp; filesUnit 5  internal sorting &amp; files
Unit 5 internal sorting &amp; files
DrkhanchanaR
 
Rpl 5-perencanaan proyek perangkat lunak
Rpl 5-perencanaan proyek perangkat lunakRpl 5-perencanaan proyek perangkat lunak
Rpl 5-perencanaan proyek perangkat lunak
f' yagami
 
[RPL2] Class Diagram dan Konsep Object Oriented (1)
[RPL2] Class Diagram dan Konsep Object Oriented (1)[RPL2] Class Diagram dan Konsep Object Oriented (1)
[RPL2] Class Diagram dan Konsep Object Oriented (1)
rizki adam kurniawan
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
Reem Alattas
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
Mohamed Loey
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
Mohamed Loey
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithm
maamir farooq
 
Perbedaan fuzzy logic, tsukamoto, sugeno
Perbedaan fuzzy logic, tsukamoto, sugenoPerbedaan fuzzy logic, tsukamoto, sugeno
Perbedaan fuzzy logic, tsukamoto, sugeno
LilyBucket
 
Algoritma Pencarian String matching
Algoritma Pencarian String matching Algoritma Pencarian String matching
Algoritma Pencarian String matching
Kukuh Setiawan
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehension
Colin Su
 
Chapter 4 stack and queue
Chapter 4   stack and queueChapter 4   stack and queue
Chapter 4 stack and queue
Muhammad Najib
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
Rj Juhith
 
Quick Sort
Quick SortQuick Sort
Quick Sort
Shweta Sahu
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
shreeuva
 
Insertion Sort
Insertion SortInsertion Sort
Insertion Sort
Brett Duncan
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
dhea zafarina
 

What's hot (20)

Context Free Grammar 1 - Materi 6 - TBO
Context Free Grammar 1 - Materi 6 - TBOContext Free Grammar 1 - Materi 6 - TBO
Context Free Grammar 1 - Materi 6 - TBO
 
Materi 7 Context Free Grammar
Materi 7   Context Free Grammar Materi 7   Context Free Grammar
Materi 7 Context Free Grammar
 
Sequential & binary, linear search
Sequential & binary, linear searchSequential & binary, linear search
Sequential & binary, linear search
 
Unit 5 internal sorting &amp; files
Unit 5  internal sorting &amp; filesUnit 5  internal sorting &amp; files
Unit 5 internal sorting &amp; files
 
Queue
QueueQueue
Queue
 
Rpl 5-perencanaan proyek perangkat lunak
Rpl 5-perencanaan proyek perangkat lunakRpl 5-perencanaan proyek perangkat lunak
Rpl 5-perencanaan proyek perangkat lunak
 
[RPL2] Class Diagram dan Konsep Object Oriented (1)
[RPL2] Class Diagram dan Konsep Object Oriented (1)[RPL2] Class Diagram dan Konsep Object Oriented (1)
[RPL2] Class Diagram dan Konsep Object Oriented (1)
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
Algorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms IIAlgorithms Lecture 3: Analysis of Algorithms II
Algorithms Lecture 3: Analysis of Algorithms II
 
Algorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern AlgorithmsAlgorithms Lecture 8: Pattern Algorithms
Algorithms Lecture 8: Pattern Algorithms
 
Binary search algorithm
Binary search algorithmBinary search algorithm
Binary search algorithm
 
Perbedaan fuzzy logic, tsukamoto, sugeno
Perbedaan fuzzy logic, tsukamoto, sugenoPerbedaan fuzzy logic, tsukamoto, sugeno
Perbedaan fuzzy logic, tsukamoto, sugeno
 
Algoritma Pencarian String matching
Algoritma Pencarian String matching Algoritma Pencarian String matching
Algoritma Pencarian String matching
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehension
 
Chapter 4 stack and queue
Chapter 4   stack and queueChapter 4   stack and queue
Chapter 4 stack and queue
 
Rahat &amp; juhith
Rahat &amp; juhithRahat &amp; juhith
Rahat &amp; juhith
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
 
Insertion Sort
Insertion SortInsertion Sort
Insertion Sort
 
Push Down Automata (PDA)
Push Down Automata (PDA)Push Down Automata (PDA)
Push Down Automata (PDA)
 

Viewers also liked

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
 

Viewers also liked (20)

Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)Algorithm and Programming (Branching Structure)
Algorithm and Programming (Branching Structure)
 
Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)Algorithm and Programming (Sequential Structure)
Algorithm and Programming (Sequential Structure)
 
Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)Data Management (Data Mining Klasifikasi)
Data Management (Data Mining Klasifikasi)
 
Algorithm and Programming (Record)
Algorithm and Programming (Record)Algorithm and Programming (Record)
Algorithm and Programming (Record)
 
Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)Algorithm and Programming (Sorting)
Algorithm and Programming (Sorting)
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
 
Ibm quantum computing
Ibm quantum computingIbm quantum computing
Ibm quantum computing
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Präsentation linkedin
Präsentation linkedinPräsentation linkedin
Präsentation linkedin
 
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
 
Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02Presentationryanair 140224071313-phpapp02
Presentationryanair 140224071313-phpapp02
 
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 ...
 
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
 
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
 
Repayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZRepayment Advisor I - Phoenix, AZ
Repayment Advisor I - Phoenix, AZ
 
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
 
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
 
ĐÁ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
 
Data Structure (Double Linked List)
Data Structure (Double Linked List)Data Structure (Double Linked List)
Data Structure (Double Linked List)
 

Similar to Algorithm and Programming (Searching)

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
 
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
Ocw chp6 2searchbinary
Ocw chp6 2searchbinaryOcw chp6 2searchbinary
Ocw chp6 2searchbinary
Prashant Rai
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
Trupti Agrawal
 
searching
searchingsearching
searching
A. S. M. Shafi
 
Searching
SearchingSearching
Searching
A. S. M. Shafi
 
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
 
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 linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
nikunjandy
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
Dr.Umadevi V
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
Nisha Soms
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
Hanif Durad
 
Unit 8 searching and hashing
Unit   8 searching and hashingUnit   8 searching and hashing
Unit 8 searching and hashing
Dabbal Singh Mahara
 
arrays in c
arrays in carrays in c
arrays in c
vidhi mehta
 
seaching internal 2 ppt.pptx
seaching internal 2 ppt.pptxseaching internal 2 ppt.pptx
seaching internal 2 ppt.pptx
SubhrasisBiswal1
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
nikshaikh786
 

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
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
 
Unit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTINGUnit 6 dsa SEARCHING AND SORTING
Unit 6 dsa SEARCHING AND SORTING
 
Ocw chp6 2searchbinary
Ocw chp6 2searchbinaryOcw chp6 2searchbinary
Ocw chp6 2searchbinary
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
 
searching
searchingsearching
searching
 
Searching
SearchingSearching
Searching
 
Binary search Algorithm
Binary search AlgorithmBinary search Algorithm
Binary search Algorithm
 
searching in data structure.pptx
searching in data structure.pptxsearching in data structure.pptx
searching in data structure.pptx
 
Lecture_Oct26.pptx
Lecture_Oct26.pptxLecture_Oct26.pptx
Lecture_Oct26.pptx
 
Algorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear SearchAlgorithm and Data Structure - Linear Search
Algorithm and Data Structure - Linear Search
 
Searching.ppt
Searching.pptSearching.ppt
Searching.ppt
 
Searching linear &amp; binary search
Searching linear &amp; binary searchSearching linear &amp; binary search
Searching linear &amp; binary search
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
 
Linear and Binary search
Linear and Binary searchLinear and Binary search
Linear and Binary search
 
Chapter 11 ds
Chapter 11 dsChapter 11 ds
Chapter 11 ds
 
Unit 8 searching and hashing
Unit   8 searching and hashingUnit   8 searching and hashing
Unit 8 searching and hashing
 
arrays in c
arrays in carrays in c
arrays in c
 
seaching internal 2 ppt.pptx
seaching internal 2 ppt.pptxseaching internal 2 ppt.pptx
seaching internal 2 ppt.pptx
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
 

More from 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 - 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 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
 

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
 
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
 

Recently uploaded

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 

Recently uploaded (20)

SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 

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: adfbipotter@gmail.com Blog: http://adfbipotter.wordpress.com Copyright © Adam Mukharil Bachtiar 2011