Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Desain & Analisis Algoritma

Presentasi serupa


Presentasi berjudul: "Desain & Analisis Algoritma"— Transcript presentasi:

1 Desain & Analisis Algoritma
Introduction Drs. Achmad Ridok M.Kom Fitra A. Bachtiar, S.T., M. Eng Imam Cholissodin, S.Kom., M.Kom Aryo Pinandito, MT.

2 Tata tertib perkuliahan
Tepat waktu dalam mengumpulkan tugas Menggunakan e-learning Aktif dalam mengerjakan tugas Harap tenang selama proses belajar mengajar Berpakaian rapi dan sopan Kehadiran minimum 80%

3 Outline 1. Introduction to The Design & Analysis of Algorithms, Fundamental Data Structures (a review) 6. Greedy Algorithm 2. Fundamentals of the Analysis of Algorithm Efficiency 7. Divide and Conquer 3. Asymptotic Notations 8. Decrease and Conquer 4. Contoh analisa algoritma dan perhitungan kompleksitasnya 9. Pemrograman dinamis (dynamic programming) 5. Brute Force Algorithms 10 Space and Time Tradeoff

4 Referensi Thomas H. Cormen, Charles E.Leiserson, Ronald L. Rivest, Introduction To Algorithms, MIT Press/McGraw-Hill, 2001 Anany Levitin, Introduction To The Design & Analysis of Algorithms, Addison Wesley, 2003

5 Algoritma: Kasus I Terdapat ember A yang berisi cairan biru dan ember B yang berisi cairan kuning. Misalkan ada sesorang yang ingin menukarkan isi cairan dari kedua ember tersebut bagaimana caranya? Jawab : Dengan cara kata-kata : Maka yang akan dilakukan yang pertama kali adalah menambah ember yaitu ember c. Ember c ini dalam keadaan kosong atau tidak berisi cairan. Setelah itu isi cairan dalam ember a dituangkan atau dipindah ke ember c maka ember a akan kosong. Jadi cairan dalam ember b bisa dipindah ke ember a dan ember c dipindah ke b.

6 Algoritma: Kasus II Misalkan seorang pemuda tiba ditepi sebuah sungai. Pemuda tersebut membawa seekor kambing, seekor srigala, dan sekeranjang sayur. Mereka hendak menyeberangi sungai. Pemuda itu menemukan sebuah perahu kecil yang hanya dapat memuat satu bawaannya setiap kali menyeberang. Situasinya dipersulit dengan kenyataan bahwa srigala tidak dapat ditinggal berdua dengan kambing (karena srigala akan memangsa kambing) atau kambing tidak dapat ditinggal berdua dengan sekeranjang sayur (karena kambing akan memakan sayur). Buatlah algoritma untuk menyeberangkan pemuda dan seluruh bawaannya itu sehingga mereka sampai keseberang sungai dengan selamat.

7 Algoritma: Kasus III Ada dua buah ember dengan kapasitas 5 liter dan 3 liter. Gunakan dua buah ember tersebut untuk mendapatkan tepat 4 liter air

8 APA ITU ALGORITMA ??

9 Definisi algoritma Algoritma adalah urutan logis langkah-langkah penyelesaian masalah. Step-by-step procedure for calculations. More precisely, it is an effective method expressed as a finite list of well-defined instructions for calculating a function

10 Notasi algoritmik Menggunakan uraian kalimat deskriptif Flow chart
Pseudo code

11 Syarat sebuah algoritma
Menurut Donald E. Knuth dalam bukunya yang berjudul The Art of Computer Programming, algoritma harus mempunyai lima ciri penting: Harus berhenti setelah melakukan beberapa langkah terbatas Setiap langkah harus didefinisikan dengan tepat dan tidak ambigu Memiliki nol atau lebih masukan Memiliki nol atau lebih keluaran Harus efektif (sederhana sehingga dapat dikerjakan dalam waktu yang masuk akal)

12 Example Algorithm A Problem: The input is a sequence of integers stored in array. Output the minimum. Algorithm A

13 Example Algorithm B This algorithm uses two temporary arrays.
copy the input a to array t1; assign n  size of input; While n > 1 For i  1 to n /2 t2[ i ]  min (t1 [ 2*i ], t1[ 2*i + 1] ); copy array t2 to t1; n n/2; 3. Output t2[1];

14 Visualize Algorithm B 34 6 5 9 20 8 11 7 Loop 1 6 5 8 7 Loop 2 5 7

15 Example Algorithm C Sort the input in increasing order. Return the
first element of the sorted data. 8 9 5 6 11 34 7 20 black box Sorting 5 6 7 8 9 11 20 34

16 Example Algorithm D For each element, test whether it is the minimum.

17 General approaches to algorithm design
Divide and conquer Greedy method Dynamic programming Basic search Graph theory Linear programming

18 Techniques can be applied to
Sorting Data retrieval Network routing Games Etc.

19 The study of algorithm How to devise/design algorithms
How to express algorithms How to validate algorithms How to analyze algorithms How to test a program

20 Importance of analyze algorithm
Need to recognize limitations of various algorithms for solving a problem Need to understand relationship between problem size and running time When is a running program not good enough? Need to learn how to analyze an algorithm's running time without coding it Need to learn techniques for writing more efficient code Need to recognize bottlenecks in code as well as which parts of code are easiest to optimize

21 Why do we analyze about them?
Understand their behavior, and (Job -- Selection, performance, modify) Improve them. (Research)

22 What do we analyze about them?
Correctness Does the input/output relation match algorithm requirement? Amount of work done (aka complexity) Basic operations to do task Amount of space used Memory used Simplicity, clarity Verification and implementation. Optimality Is it impossible to do better?

23 What is the running time of this algorithm?
PUZZLE(x) while x != 1     if x is even      then  x = x / 2      else x = 3x + 1 Sample run:  7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1

24 The Selection Problem (1/2)
Problem: given a group of n numbers, determine the kth largest Algorithm 1 Store numbers in an array Sort the array in descending order Return the number in position k

25 The Selection Problem(2/2)
Algorithm 2 Store first k numbers in an array Sort the array in descending order For each remaining number, if the number is larger than the kth number, insert the number in the correct position of the array Return the number in position k Which algorithm is better?

26 Example what is an algorithm?
Problem: Input = sequence of integers stored in an array. Output = output the minimum. Algorithm INPUT OUTPUT instance m:= a[1]; for I:=2 to size of input if m > a[I] then m:=a[I]; return s 25, 90, 53, 23, 11, 34 11 m Data-Structure

27 Define Problem Problem: Description of Input-Output relationship
Algorithm: A sequence of computational step that transform the input into the output. Data Structure: An organized method of storing and retrieving data. Our task: Given a problem, design a correct and good algorithm that solves it.

28 Which algorithm is better?
The algorithms are correct, but which is the best? Measure the running time (number of operations needed). Measure the amount of memory used. Note that the running time of the algorithms increase as the size of the input increases. Thursday, November 15, 2018 Design and Analysis of Computer Algorithm

29 Design and Analysis of Computer Algorithm
What do we need? Correctness: Whether the algorithm computes the correct solution for all instances Efficiency: Resources needed by the algorithm 1. Time: Number of steps. 2. Space: amount of memory used. Measurement “model”: Worst case, Average case and Best case. Thursday, November 15, 2018 Design and Analysis of Computer Algorithm

30 Design and Analysis of Computer Algorithm
Time vs. Size of Input Measurement parameterized by the size of the input. The algorithms A,B,C are implemented and run in a PC. Algorithms D is implemented and run in a supercomputer. Let Tk( n ) be the amount of time taken by the Algorithm 4 2 Tc (n) Running time (second) Td(n) Tb (n) Ta (n) 500 1000 Input Size Design and Analysis of Computer Algorithm Thursday, November 15, 2018Thursday, November 15, 2018

31 Kompleksitas algoritma
Ukuran yang digunakan untuk menyatakan keefektifan sebuah algoritma Ukuran yang digunakan untuk mengukur seberapa besar pertumbuhan komputasi sebuah algoritma

32 PENILAIAN QUIZ = 10% TUGAS = 30% (60% final project + 40% tugas)
UTS = 30% UAS = 30%

33 Lain-Lain Dosen : Pembentukan Kelompok (maks 5 org/kelompok)
Nama : Imam Cholissodin, S.Kom., M.Kom Hp : Pembentukan Kelompok (maks 5 org/kelompok) Ketua Kelas A : Nama : Moch. Arius eko cahyono Hp :

34 Terimakasih… See you next week


Download ppt "Desain & Analisis Algoritma"

Presentasi serupa


Iklan oleh Google