1 / 25

Design and A n alysis of Algorithm Introduction

Design and A n alysis of Algorithm Introduction. Aryo Pinandito, ST, M.MT - PTIIK UB. Algoritma. Apa itu Algoritma ? Kenapa memerlukan algoritma ? Asal Usul Kata

monita
Download Presentation

Design and A n alysis of Algorithm Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Design and Analysis of AlgorithmIntroduction Aryo Pinandito, ST, M.MT - PTIIK UB

  2. Algoritma • ApaituAlgoritma? • Kenapamemerlukanalgoritma? AsalUsul Kata • Kata algoritmadarinama Abu Ja'fat Mohammed Ibn Musa al-Khowarizmi, seorangilmuan Persia yang menulisbukuberjudulKitab al jabrw'al-muqabala (rules of restoration and reduction) sekitartahun 825 Masehi • Tahun1950 istilahalgorithmselaludiasosiasikandenganEuclid's algorithm, yaitusuatu proses yang menjelaskancaramencaribilanganpembagiterbesaruntukduabuahbilangan.

  3. DefinisiAlgoritma • Merriam-Webster's Collegiet Dictionaryistilahalgorithmdiartikansebagaiprosedurlangkah demi langkahuntukmemecahkanmasalahataupenyelesaiansuatutugaskhususnyadenganmenggunakanbantuankomputer • 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

  4. SyaratAlgoritma • Menurut Donald E Knuth (The Art of Computer Programming), algoritmaharusmemenuhipersyaratanberikut: • Input: • Memilikinolataulebihmasukandariluar. • Output • Memilikiminimal satubuahkeluaran. • Definiteness (pasti) • Memilikiinstruksi-instruksi yang jelasdantidakambigu. • Finiteness (adabatas): • Memilikititikberhenti (stopping role) • Effectiveness (tepatdanefisien) • Sebisamungkinharusdapatdilaksanakandanefektif.

  5. Algorithm Definition Overview • Algoritmamendeskripsikankanurutanlangkah-langkah yang diperlukanuntukmenyelesaikansuatupermasalahandan memilikiciri-cirisebagaiberikut; • Selalumemilikiterminasi/langkahakhir • Setiaplangkahdinyatakansecarajelas, tegas, dan tidakbermaknaganda (ambigu) • Setiaplangkahsederhana, sehinggakinerjanyaefisien • Memberikanhasil (output), mungkindengansatuatautanpa input.

  6. What is a Program? • A program is the expression of an algorithm in a programming language • a set of instructions which the computer will follow to solve a problem

  7. AlgoritmadalamKerangkaPenyelesaianPermasalahan

  8. Algoritma: Kasus I • Terdapat ember A yang berisicairanbirudan ember B yang berisicairankuning. Misalkanadasesorang yang inginmenukarkanisicairandarikedua ember tersebutbagaimanacaranya?

  9. Algoritma: KasusII • Adaduabuah ember dengankapasitas 5 liter dan 3 liter. Gunakanduabuah ember tersebutuntukmendapatkantepat 4 liter air.

  10. Algoritma: KasusIII • Misalkanseorangpemudatibaditepisebuahsungai. Pemudatersebutmembawaseekorkambing, seekorserigala, dansekeranjangsayur. Merekahendakmenyeberangisungai. Pemudaitumenemukansebuahperahukecilyang hanyadapatmemuatsatubawaannyasetiapkali menyeberang. Situasinyadipersulitdengankenyataanbahwaserigalatidakdapatditinggalberduadengankambing(karenaserigalaakanmemangsakambing) ataukambingtidakdapatditinggalberduadengansekeranjangsayur (karenakambingakanmemakansayur). Bagaimanacaramenyeberangkanpemudadanseluruhbawaannyadenganselamat?

  11. Notasialgoritmik • Menggunakanuraiankalimatdeskriptif • Flow chart • Pseudo code

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

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

  14. 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?

  15. Kompleksitas algoritma • The complexity of an algorithm is simply the amount of work the algorithm performs to complete its task. • Ukuran yang digunakanuntukmenyatakankeefektifansebuahalgoritma • Ukuran yang digunakanuntukmengukurseberapabesarpertumbuhankomputasisebuahalgoritma • Asymptotic Notations: • O (big oh) •  (big omega) •  (big theta)

  16. Example: The Minimum Number Problem • Input: a sequence of integers stored in array. • Problem: Output the minimum. • Algorithm: Search

  17. Algorithm A

  18. Algorithm B 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; • Output t2[1];

  19. Visualization of Algorithm B 7 34 6 5 9 20 8 11 Loop 1 5 8 7 6 Loop 2 7 5 Loop 3 5

  20. 7 34 6 5 9 20 8 11 5 6 7 8 9 11 20 34 Algorithm C • Using sort method to sort the input in increasing orderand return the first element of the sorted data. black box Sorting

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

  22. 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. Which Algorithm Is Better?

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

  24. 4 Td(n) Tc(n) Running time (second) 2 0 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 Tb (n) Ta (n) 500 1000 Input Size

  25. 감사합니다 Grazias Kiitos Gratias Danke ﺷﻜﺮﺍﹰ 谢谢 TerimaKasih Merci Thank You धन्यवाद ありがとうございます

More Related