Algorithms and Programming Searching

Slides:



Advertisements
Presentasi serupa
Pencarian ( Searching)
Advertisements

BAB III – ARRAY STATIS II
Desain Dan Analisis Algoritma
1 Algoritma Bahasa Pemrograman dan Bab 1.1. Pengertian Algoritma.
PENGURUTAN (SORTING).
PENCARIAN (SEARCHING)
Modul-8 : Algoritma dan Struktur Data
Chapter 9 SEARCHING ALGORITHM Program Studi Ekstensi DTE FTUI Slides © 2007.
LOGIKA ALGORITMA Pertemuan 6.
2. Introduction to Algorithm and Programming
Searching.
Array Processing & Modular
Algoritma dan Struktur Data
REPETITION CONTROL STRUCTURES
Testing Implementasi Sistem Oleh :Rifiana Arief, SKom, MMSI
1 Diselesaikan Oleh KOMPUTER Langkah-langkah harus tersusun secara LOGIS dan Efisien agar dapat menyelesaikan tugas dengan benar dan efisien. ALGORITMA.
Menulis Kolom  Kolom adalah opini atau artikel. Tidak seperti editorial, kolom memiliki byline.  Kolom Biasanya ditulis reguler. Biasanya mingguan atau.
Algoritma dan Struktur Data
9.3 Geometric Sequences and Series. Objective To find specified terms and the common ratio in a geometric sequence. To find the partial sum of a geometric.
Binary Search Tree. Sebuah node di Binary Search Tree memiliki path yang unik dari root menurut aturan ordering – Sebuah Node, mempunyai subtree kiri.
Algoritma dan Pemrograman Subrutin
While … do … Repeat … until … For … to … do …
MATERI PERKULIAHAN ANALISIS ALGORITMA
MATERI PERKULIAHAN ANALISIS ALGORITMA
Algoritma Pencarian (searching)
Fondasi Pemrograman & Struktur Data
Algoritma dan Pemrograman STRUKTUR PEMILIHAN (SELECTION) lanjutan
Induksi Matematika.
KUG1A3 Algoritma& Pemrograman
KUG1A3 Algoritma& Pemrograman
IF … THEN …, IF … THEN … ELSE … CASE … OF …
Algoritma dan Pemrograman Searching
Pencarian pada Array Tim PHKI Modul Dasar Pemrograman
Dynamic Array and Linked List
Algoritma dan Pemrograman Sorting
Struktur data Oleh: Tim Struktur Data IF ARRAY STATIS.
Branch and Bound Lecture 12 CS3024.
Konsep pemrograman LOOP
Algoritma dan Pemrograman Searching
PENGURUTAN (SORTING).
CSG523/ Desain dan Analisis Algoritma
Linked List.
STRUKTUR DATA Array Statis.
Algoritma dan Pemrograman Subrutin
Pertemuan 24 Teknik Searching
Analisis Algoritma dan Struktur Data
CSG3F3/ Desain dan Analisis Algoritma
MATERI PERKULIAHAN ANALISIS ALGORITMA
Algoritma dan Pemrograman Sorting
BINARY SEARCH Tim Algoritma Pemrograman Teknik Informatika
SEARCHING (PENCARIAN)
Seleksi Kondisi merupakan perintah yang memungkinkan pemilihan atas perintah yang akan dijalankan sesuai dengan kondisi tertentu. Operator yang digunakan.
Algoritma dan Pemrograman Subrutin
STRUKTUR DATA Array Statis.
MATRIKS (ARRAY 2 DIMENSI)
Algoritma dan Pemrograman Sorting
ARRAY STATIS Sri Nurhayati, MT.
Bahasa Pemrograman (Pemrograman Visual)
Algoritma dan Pemrograman Searching
STRUKTUR DATA Sri Nurhayati, MT.
Algoritma dan Pemrograman STRUKTUR PEMILIHAN (SELECTION) lanjutan
Linked List Oleh: Tim Struktur Data IF - UNIKOM.
ARRAY STATIS Sri Nurhayati, MT.
SORTING (PENGURUTAN).
Algoritma dan Struktur Data
Algoritma & Pemrograman 1 Achmad Fitro The Power of PowerPoint – thepopp.com Chapter 3.
Lesson 2-1 Conditional Statements 1 Lesson 2-1 Conditional Statements.
HughesNet was founded in 1971 and it is headquartered in Germantown, Maryland. It is a provider of satellite-based communications services. Hughesnet.
Perulangan (Loop) Oleh : Tim Teaching
Draw a picture that shows where the knife, fork, spoon, and napkin are placed in a table setting.
Transcript presentasi:

Algorithms and Programming Searching Adam Mukharil Bachtiar English Class Informatics Engineering 2011 Algorithms and Programming Searching

Definition of Searching Steps of the Day 1 Definition of Searching 2 Sequential Search 3 Binary Search Let’s Start

Definition of Searching 1 Definition of Searching All About Searching

Process that search the value in group of data Process that search the value in group of data. This process can produce FOUND or NOT FOUND value. What is Searching

Sequential search / Linear search Binary search Algorithms of Sorting

2 Sequential Search Definition and Structures of Sequential Search

What is Sequential Search 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. What is Sequential Search

Methods in Sequential Search Without boolean Without sentinel Use sentinel Use boolean Methods in Sequential Search

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

Sequential Search Use Sentinel 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. Sequential Search Use Sentinel

Ilustration of Seq. Search Use Sentinel Data that was sought: 9 Number Result: Data was found in Number[3] Data that was sought: 10 Result: Data was not found sentinel 5 1 9 4 2 [1] [2] [3] [4] [5] [6] sentinel 5 1 9 4 2 10 [1] [2] [3] [4] [5] [6]

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

Sequential Search Use Boolean Its searching process is similar with another sequential search method. Involves one boolean variable. Sequential Search Use Boolean

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) output(data_cari,’ ditemukan pada indeks ke-’,i) output(data_cari,’ tidak ditemukan’) EndProcedure

3 Binary Search Definition and Structures of Binary Search

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. What is Binary Search

Case Example of Binary Search Data that was sought: 7 Number Result: ? Case Example of Binary Search 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) Ia  k + 1 Ib  k – 1 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

GRACIAS THANK YOU Copyright © Adam Mukharil Bachtiar 2011 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