1 / 15

Pertemuan 13 DYNAMIC PROGRAMMING : FIBONACCI SEQUENCE PROBLEM

Pertemuan 13 DYNAMIC PROGRAMMING : FIBONACCI SEQUENCE PROBLEM. Matakuliah : T0034 / Perancangan & Analisis Algoritma Tahun : 2008. DYNAMIC PROGRAMMING.

jeb
Download Presentation

Pertemuan 13 DYNAMIC PROGRAMMING : FIBONACCI SEQUENCE PROBLEM

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. Pertemuan 13DYNAMIC PROGRAMMING :FIBONACCI SEQUENCE PROBLEM Matakuliah : T0034 / Perancangan & Analisis Algoritma Tahun : 2008

  2. DYNAMIC PROGRAMMING • Dynamic Programming adalah metode penyelesaian masalah yang dapat digunakan jika solusi sebuah problem dapat dipandang sebagai deretan dari beberapa keputusan. • Dynamic Programming vs Metode Greedy • Dynamic Programming menghasilkan solusi yang optimal, karena tidak menggunakan local optimum seperti Metode Greedy • Dynamic Programming vs Metode Naive • Metode Naive : menghitung semua Solusi Feasible • Dynamic Programming tidak perlu menghitung semua kemungkinan, menghemat banyak waktu dan lebih efisien. [buku utama, bab 7.1]

  3. APLIKASI DYNAMIC PROGRAMMING • Fibonacci Sequence Problem • Coin Change Problem • Multistage Graph Problem • Travening Salesman Problem • 0/1 Knapsac Problem

  4. FIBONACCI SEQUENCE • Fibonacci Sequence adalah sebuah deret dimana setiap elemen merupakan hasil penjumlahan 2 elemen sebelumnya. • Misalkan kita memiliki deret Fibonacci f(1),f(2),f(3),f(4),... • Nilai f(3) dihitung dari f(1)+f(2). Nilai f(4) dihitung dari f(2)+f(3) dan seterusnya. [buku utama, bab 7.2]

  5. 1 module fibo(n) 2 if (n=0) or (n=1) then 3 result=n 4 else 5 result=fibo(n-1)+fibo(n-2) 6 end if 7 end module 1 for i=1 to 100 do 2 display fibo(i),” ” 3 end for FIBONACCI DENGAN METODE NAIVE [buku utama, pseudocode 7.1]

  6. RECURSIVE CALL TREE [buku utama, ilustrasi 7.1]

  7. JUMLAH PEMANGGILAN FUNGSI [buku utama, tabel 7.1]

  8. REDUNDANSI [buku utama, ilustrasi 7.2]

  9. MEMOIZATION [buku utama, ilustrasi 7.3]

  10. JUMLAH PEMANGGILAN FUNGSI • Setelah ditambahkan memoization [buku utama, tabel 7.2]

  11. 1 module fibo(n) 2 if (n=0) or (n=1) then 3 result=n 4 else 5 if F[n]=0 then 6 F[n]=fibo[n-1]+fibo[n-2] 7 end if 8 result=F[n] 9 end if 10 end module 1 for 1=1 to 100 do 2 F[i]=0 3 end for 4 for i=1 to 100 do 5 display fibo(i),” ” 6 end for FIBONACCI DENGAN MEMOIZATION [buku utama, pseudocode 7.2]

  12. TOP-DOWN vs BOTTOM-UP • Top-Down • Berusaha mencapai hasil akhir dengan cara menghitung komponen-komponen penyusun hasil tersebut. • Biasanya berbentuk fungsi rekursif. • Bottom-Up • Berusaha membentuk solusi dengan menghitung dari awal, secara terstruktur menuju solusi. • Biasanya berbentuk perulangan biasa.

  13. LATIHAN • Pseudocode Fibonacci dengan Memoization yang terdapat dalam penjelasan pertemuan ini menggunakan pendekatan Top-Down. Buatlah versi Bottom-Up nya! • Jelaskan cara kerjanya!

  14. REVIEW • Apa yang sudah dipahami? • Apa yang akan dibahas selanjutnya?

More Related