Design and Analysis of Algorithm

dokumen-dokumen yang mirip
Design and Analysis of Algorithm

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Design and Analysis of Algorithm

Analisis Algoritm. Fundamentals of the Anlysis of Algorithm Efficiency

Adam Mukharil Bachtiar English Class Informatics Engineering Algorithms and Programming Searching

Analisis dan Strategi Algoritma

Design and Analysis of Algorithms CNH2G3- Week 5 Kompleksitas waktu algoritma rekursif part 2: Metode Karakteristik

Design and Analysis of Algorithms CNH2G3- Week 8 Greedy Algorithm

Analisa dan Perancangan Algoritma. Ahmad Sabri, Dr Sesi 1: 9 Mei 2016

SATUAN ACARA PERKULIAHAN PERANCANGAN DAN ANALISIS ALGORITMA ** (S1/TEKNIK INFORMATIKA) PTA 2010/2011

Design and Analysis of Algorithms CNH2G3- Week 7 Brute Force Algorithm Part 2: Exhaustive Search

Design and Analysis of Algorithms CNH2G3- Week 4 Kompleksitas waktu algoritma rekursif part 1

PENELITIAN OPERASIONAL I (TIN 4109)

Jurnal Evolusi Volume 5 No evolusi.bsi.ac.id

PENELITIAN OPERASIONAL I (TIN 4109)

Nama Soal Pembagian Ring Road Batas Waktu 1 detik Nama Berkas Ringroad[1..10].out Batas Memori 32 MB Tipe [output only] Sumber Brian Marshal

Analisa dan Perancangan Algoritma. Ahmad Sabri, Dr Sesi 2: 16 Mei 2016

SILABUS MATAKULIAH. Indikator Pokok Bahasan/Materi Aktifitas Pembelajaran

ABSTRACT. Keyword: Algorithm, Depth First Search, Breadth First Search, backtracking, Maze, Rat Race, Web Peta. Universitas Kristen Maranatha

Dynamic Programming Matakuliah Desain & Analisis Algoritma (CS 3024) ZK Abdurahman Baizal STT Telkom Bandung

ALGORITMA DAN PEMROGRAMAN

ALGORITMA DOUBLE SCALING UNTUK MENYELESAIKAN PERMASALAHAN MINIMUM COST FLOW DAN IMPLEMENTASINYA PADA PROGRAM KOMPUTER

1/5. while and do Loops The remaining types of loops are while and do. As with for loops, while and do loops Praktikum Alpro Modul 3.

2. Sebuah prosedur langkah demi langkah yang pasti untuk menyelesaikan sebuah masalah disebut : a. Proses b. Program c. Algoritma d. Prosesor e.

Pengantar Analisa Algoritma

Algoritma Pencarian Blind. Breadth First Search Depth First Search

Analisis Algoritma Bubble Sort

Langkah Awal menuju Analisis Kompleksitas Algoritma

PENGUJIAN PERANGKAT LUNAK

Objectives. Struktur Data & Algoritme (Data Structures & Algorithms) Sort. Outline. Bubble Sort: idea. Bubble Sort. Sorting

ANALISIS PERBANDINGAN ALGORITMA SELECTION SORT DENGAN MERGE SORT

Simple Sorting Techniques

STRUKTUR DATA KULIAH KE : 3 ALGORITMA

Pengantar Strategi Algoritma

Alternatif Pembelajaran. Mengamati 1. Menanggapi gambar 2. Menonton video tentang. 3. Membaca daftar ekspresi kebahasaan.

Sorting Algorithms. Algoritma dan Struktur Data. Sorting algorithms

Method & Tools for Program Analysis & Design

Analisis Algoritma: Anany Levitin, Introduction to Design and Analysis of Algorithm, 3 rd Edition, Pearson Education, Inc.

Melakukan Operasi Logika

TIF APPLIED MATH 1 (MATEMATIKA TERAPAN 1) Week 3 SET THEORY (Continued)

PROGRAM STUDI S1 SISTEM KOMPUTER UNIVERSITAS DIPONEGORO. Oky Dwi Nurhayati, ST, MT

Pengenalan Sistem Bilangan Biner dan Gerbang Logika

Analisa Algoritma. Konsep Algoritma

Sorting Algorithms. Buble Sort

Langkah Awal menuju Analisis Kompleksitas Algoritma

RENCANA PEMBELAJARAN SEMESTER (RPS)

RENCANA PEMBELAJARAN SEMESTER (RPS)

RENCANA PEMBELAJARAN SEMESTER (RPS)

Sorting Algorithms. Definisi

Analisis Kecepatan Sorting Dengan Notasi Big O

JARINGAN KOMPUTER. 2. What is the IP address and port number used by gaia.cs.umass.edu to receive the file. gaia.cs.umass.edu :

KATA PENGANTAR. Puji syukur kami panjatkan ke hadirat Alloh SWT atas terbentuknya Lembar Tugas

Rahasia Cermat & Mahir Menguasai Akuntansi Keuangan Menengah (Indonesian Edition)

RENCANA PROGRAM KEGIATAN PERKULIAHAN SEMESTER (RPKPS)

Design and Analysis of Algorithms CNH2G3- Week 6 Brute Force Algorithm Part 1: Design Strategy

JARINGAN KOMPUTER : ANALISA TCP MENGGUNAKAN WIRESHARK

LINEAR PROGRAMMING-1

NASKAH UJIAN UTAMA. JENJANG/PROG. STUDI : DIPLOMA TIGA / MANAJEMEN INFORMATIKA HARI / TANGGAL : Kamis / 18 FEBRUARI 2016

Pemrograman Lanjut. Interface

JURNAL TEKNOLOGI INFORMASI & PENDIDIKAN ISSN : VOL. 6 NO. 1 Maret 2013

KONTRAK PEMBELAJARAN (KP) MATA KULIAH. Algoritma dan Pemrograman

Quick Sort dan Merge Sort. Arna Fariza Yuliana Setiowati

PENGENALAN ANALISIS ALGORITMA

PENYELESAIAN MASALAH PENUGASAN YANG DIPERUMUM DENGAN MENGGUNAKAN ALGORITMA BRANCH-AND-BOUND YANG DIREVISI

ANALISIS PERBANDINGAN ALGORITMA BUBBLE SORT, MERGE SORT, DAN QUICK SORT DALAM PROSES PENGURUTAN KOMBINASI ANGKA DAN HURUF

Pengantar Strategi Algoritmik. Oleh: Rinaldi Munir

Studi Mengenai Perbandingan Sorting Algorithmics Dalam Pemrograman dan Kompleksitasnya

Sorting Algorithms. Divide and Conquer

UNIVERSITAS GUNADARMA

Data Structures. Class 5 Pointer. Copyright 2006 by The McGraw-Hill Companies, Inc. All rights reserved.

Minimum Spanning Trees algorithm

SEARCHING & SORTING. Pendahuluan

Pendahuluan. Sebuah algoritma tidak saja harus benar, tetapi juga harus efisien. Algoritma yang bagus adalah algoritma yang efektif dan efisien.

Procedure Cetak ( DTATA :array [1..10] of integer, N ; Integer ) ;

Sebuah algoritma tidak saja harus benar, tetapi juga harus mangkus (efisien). Algoritma yang bagus adalah algoritma yang mangkus.

STRATEGI DIVIDE AND CONQUER

Kompleksitas Algoritma untuk Penyelesaian Persoalan Penukaran Koin dengan Algoritma Greedy

365 Menu Sukses MP-ASI selama 1 tahun Menu Pendamping ASI untuk Bayi Usia 7-18 Bulan (Indonesian Edition)

PAM 271 PENGANTAR TEORI GRAF

PIRANTI LUNAK UNTUK MENDESAIN PROGRAM DALAM BAHASA PEMROGRAMAN C BERDASARKAN HOARE LOGIC

Kompleksitas Algoritma

PENDEKATAN ALGORITMA PEMROGRAMAN DINAMIK DALAM MENYELESAIKAN PERSOALAN KNAPSACK 0/1 SKRIPSI SRI RAHAYU


Design and Analysis Algorithm. Ahmad Afif Supianto, S.Si., M.Kom. Pertemuan 08

Fakultas Teknologi Informasi

ANALISIS ALGORITMA BABY-STEP GIANT-STEP DAN POHLIG-HELLMAN UNTUK MENYELESAIKAN MASALAH LOGARITMA DISKRIT SKRIPSI ETTY WINITA ROISKA SIMBOLON

Kompleksitas Algoritma

ANALISIS ALGORITMA. Disusun Oleh: Analisis Masalah dan Running Time. Adam Mukharil Bachtiar Teknik Informatika UNIKOM

Statistik Bisnis 1. Week 9 Discrete Probability

Algoritma dan Struktur Data. Searching dan Sorting

Masalah Penugasan (Assignment Problem) Bentuk khusus metode transportasi

Review Teori P dan NP

Algoritma Greedy (Bagian 2) IF2251 Strategi Algoritmik Oleh: Rinaldi Munir

Kompleksitas Algoritma

Arsitektur Komputer. Pertemuan ke-2 - Aritmatika Komputer >>> Sistem bilangan & Format Data - Perkembangan Perangkat Keras Komputer

Transkripsi:

Design and Analysis of Algorithm Week 1: Introduction Dr. Putu Harry Gunawan 1 1 Department of Computational Science School of Computing Telkom University Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 1 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 2 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 3 / 41

Goals Sebelum UTS: 1 Mahasiswa mampu untuk mejelaskan kompleksitas waktu pada suatu algoritma 2 Mahasiswa mampu menganalisis kompleksitas suatu algoritma. Setelah UTS: 1 Mahasiswa mampu membedakan tipe dan karakteristik masing-masing algoritma. 2 Mahasiswa mampu merancang suatu algoritma berdasarkan contoh-contoh algoritma yang sudah diberikan. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 4 / 41

References Figure : Main reference. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 5 / 41

Grading TUGAS 15% KUIS 20% UTS 25% TUGAS BESAR 15% UAS 25% NB: Bonus jika absensi mencapai 100% (Membuat buku tugas yang akan dikumpul setiap pengumpulan tugas) Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 6 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 7 / 41

What is algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 8 / 41

Algorithm An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in a finite amount of time. Can be represented various forms Unambiguity/clearness Effectiveness Finiteness/termination Correctness Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 9 / 41

Example of computational domain Statement of problem: Input: A sequence of n numbers < a 1, a 2,, a n > Output: A reordering of the input sequence < a 1, a 2,, a n > so that a i a j whenever i < j Instance: The sequence < 5, 3, 2, 8, 3 > Algorithms: Selection sort Insertion sort Merge sort (many others) Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 10 / 41

Some well-known of computational domain Sorting Searching Shortest paths in a graph Minimum spanning tree Primality testing Traveling salesman problem Knapsack problem Chess Towers of Hanoi Program termination Some of these problems dont have efficient algorithms, or algorithms at all! Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 11 / 41

Basic Issues Related to Algorithms How to design algorithms How to express algorithms Proving correctness Efficiency (or complexity) analysis Theoretical analysis Empirical analysis Optimality Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 12 / 41

Algorithms and design strategies Brute force Divide and conquer Decrease and conquer Transform and conquer Greedy approach Dynamic programming Backtracking and branch-and-bound Space and time tradeoffs Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 13 / 41

Analysis algorithms How good is the algorithm? Correctness Time efficiency Space efficiency Does there exist a better algorithm? Lower bounds Optimality Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 14 / 41

Euclid s algorithm Problem: Find gcd(m, n), the greatest common divisor of two nonnegative, not both zero integers m and n Examples: gcd(60,24) = 12, gcd(60,0) = 60, gcd(0,0) =? Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 15 / 41

Euclid s algorithm Problem: Find gcd(m, n), the greatest common divisor of two nonnegative, not both zero integers m and n Examples: gcd(60,24) = 12, gcd(60,0) = 60, gcd(0,0) =? Euclids algorithm is based on repeated application of equality gcd(m, n) = gcd(n, m mod n) until the second number becomes 0, which makes the problem trivial. Example: gcd(60,24) Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 15 / 41

Euclid s algorithm Problem: Find gcd(m, n), the greatest common divisor of two nonnegative, not both zero integers m and n Examples: gcd(60,24) = 12, gcd(60,0) = 60, gcd(0,0) =? Euclids algorithm is based on repeated application of equality gcd(m, n) = gcd(n, m mod n) until the second number becomes 0, which makes the problem trivial. Example: gcd(60,24) = gcd(24,12) = gcd(12,0) = 12 Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 15 / 41

Euclid s algorithm Exercise: Make an algorithm for computing the gcd(m,n)! r. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 16 / 41

Euclid s algorithm Exercise: Make an algorithm for computing the gcd(m,n)! Step 1 If n = 0, return m and stop; otherwise go to Step 2 Step 2 Divide m by n and assign the value of the remainder to r Step 3 Assign the value of n to m and the value of r to n. Go to Step 1. while n 0 do r m mod n m n n r return m Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 16 / 41

Another method to compute gcd Consecutive integer checking algorithm Step 1 Assign the value of min{m, n} to t Step 2 Divide m by t. If the remainder is 0, go to Step 3; otherwise, go to Step 4 Step 3 Divide n by t. If the remainder is 0, return t and stop; otherwise, go to Step 4 Step 4 Decrease t by 1 and go to Step 2 Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 17 / 41

Another method to compute gcd Consecutive integer checking algorithm Step 1 Assign the value of min{m, n} to t Step 2 Divide m by t. If the remainder is 0, go to Step 3; otherwise, go to Step 4 Step 3 Divide n by t. If the remainder is 0, return t and stop; otherwise, go to Step 4 Step 4 Decrease t by 1 and go to Step 2 Is this slower than Euclids algorithm? How much slower? Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 17 / 41

Another method to compute gcd Consecutive integer checking algorithm Step 1 Assign the value of min{m, n} to t Step 2 Divide m by t. If the remainder is 0, go to Step 3; otherwise, go to Step 4 Step 3 Divide n by t. If the remainder is 0, return t and stop; otherwise, go to Step 4 Step 4 Decrease t by 1 and go to Step 2 Is this slower than Euclids algorithm? How much slower? O(n), if n m, vs O(log n) Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 17 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 18 / 41

Efficiency Pertimbangan Memilih algoritma : Kebenaran Tepat guna (efektif) output sesuai dengan inputnya sesuai dengan permasalahan Kemudahan/ kesederhanaan Untuk dipahami Untuk diprogram (proses coding) Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 19 / 41

Efficiency Pertimbangan Memilih algoritma : Kecepatan Algoritma: Berkaitan dengan kecepatan eksekusi program Hemat Biaya: mengacu pada kebutuhan memory Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 20 / 41

Efficiency Keempatnya sulit dicapai bersamaan, dan biasanya yang diutamakan adalah efisiensi (cepat dan hemat) Analisis Algoritma : menganalisis efisiensi algoritma, yang mencakup : efisiensi waktu (kecepatan) banyaknya operasi yang dilakukan efisiensi memori struktur data dan variabels yang digunakan Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 21 / 41

Efficiency Algoritma yang bagus adalah algoritma yang efisien Algoritma yang efisien ialah algoritma yang meminimumkan kebutuhan waktu dan ruang/memori. Kebutuhan waktu dan ruang suatu algoritma bergantung pada ukuran masukan (n), yang menyatakan jumlah data yang diproses. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 22 / 41

Efficiency Question: Mana yang lebih baik : menggunakan algoritma yang waktu eksekusinya cepat dengan komputer standard atau menggunakan algoritma yang waktunya tidak cepat tetapi dengan komputer yang cepat? Watch Video Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 23 / 41

Efficiency Misal dipunyai : Algoritma dengan waktu eksekusi dalam orde 2 n Sebuah komputer dengan kecepatan 10 4 2 n n = 10 1/10 detik n = 20 2 menit n = 30 lebih dari satu hari n = 38 1 tahun Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 24 / 41

Efficiency Misal dipunyai : Algoritma dengan waktu eksekusi dalam orde 2 n Sebuah komputer dengan kecepatan 10 6 x2 n n = 45 1 tahun Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 25 / 41

Efficiency Misal dipunyai : Algoritma dengan waktu eksekusi dalam orde n 3 Sebuah komputer dengan kecepatan 10 4 xn 3 n = 900 1 hari n = 6800 1 tahun Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 26 / 41

Efficiency Misal dipunyai : Mengapa kita memerlukan algoritma yang efisien? Lihat grafik di bawah ini. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 27 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 28 / 41

Rules Make a group Each group consists of 5 or more peoples Choose a leader Prepare the answer sheet Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 29 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 30 / 41

Problem 1 Buatlah algoritma untuk membuat Jus Nanas! Usahakan menggunakan sintax-syntax berikut sebanyak mungkin Comment Assignment Logical relational while loop for loop repeat loop conditional case input output procedure r. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 31 / 41

Problem 1 Buatlah algoritma untuk membuat kopi! Usahakan menggunakan sintax-syntax berikut sebanyak mungkin Comment Assignment Logical relational while loop for loop repeat loop conditional case input output procedure r. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 32 / 41

Problem 2 Buatlah algoritma untuk membuat Sambal Balado! Usahakan menggunakan sintax-syntax berikut sebanyak mungkin Comment Assignment Logical relational while loop for loop repeat loop conditional case input output procedure r. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 33 / 41

Problem 2 Buatlah algoritma untuk membuat Lumpia Basah! Usahakan menggunakan sintax-syntax berikut sebanyak mungkin Comment Assignment Logical relational while loop for loop repeat loop conditional case input output procedure r. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 34 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 35 / 41

Problem 3 Given the following algorithm: if the input 60, 35, 81, 98, 14, 47, what is the output? Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 36 / 41

Outline 1 Introduction About this course Beginning of Algorithm The efficiency of algorithm 2 Exercise Rules Skilled Group Careful Group Smart Group 3 Homeworks Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 37 / 41

Problem 4 Design a algorithm that reads as its inputs the (x, y) coordinates of the endpoints of two line segments P 1, Q 1 and P 2, Q 2 and determines whether the segments have a common point. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 38 / 41

Problem 5 Design an algorithm for the following problem: Given a set of n points in the Cartesian plane, determine whether all of them lie on the same circumference. Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 39 / 41

Homeworks Compare two algorithms of shorting problem, give an analysis and a comment for the each algorithms. Compare two algorithms of searching problem, give an analysis and a comment for the each algorithms. Prove the following relations 1 1 + 2 + 3 + + n = n(n+1) 2 2 1 + 3 + 5 + + (2n 1) = n 2 3 if n Z and n 0, then n i=0 i i! = (n + 1)! 1 Compute the following sums. 1 2 3 4 5 n+1 i=3 1 n+1 i=3 i n 1 i=0 n i=0 3j+1 n i=1 i(i + 1) n j=1 ij Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 40 / 41

The end of week 1 Thank you for your attention! Dr. Putu Harry Gunawan (Telkom University) Design and Analysis of Algorithm 41 / 41