Upload presentasi
Presentasi sedang didownload. Silahkan tunggu
1
Desain dan Analisis Algoritma
Pertemuan 6 Brute Force
2
Salah satu teknik desain algoritma
Brute Force Salah satu teknik desain algoritma A straightforward approach to solving problems, usually directly based on the problem statement and definitions of the concepts involved Examples: Computing an (a > 0, n a nonnegative integer) Computing n! Searching for a key of a given value in a list
3
Brute Force Sorting Apa sorting itu? A0 ≤ A1 ≤ A2 ≤ … An-1 ≤ An
Perhatikan bahwa setelah sorting : A0 merupaka elemen dengan nilai terkecil A1 merupaka elemen dengan nilai terkecil setelah A0 … An merupaka elemen dengan nilai terbesar
4
Brute Force Sorting Dengan definisi di atas, susunlah algoritma brute force untuk mensorting A[0..n-1]
5
Brute Force Sorting
6
Selection Sort
7
Selection Sort Analisalah kompleksitas waktu selection sort Ө(n2)
8
Alternative Brute Force Sorting
Apa sorting itu? A0 ≤ A1 ≤ A2 ≤ … An-1 ≤ An Perhatikan bahwa setelah sorting : A0 ≤ A1 A1 ≤ A2 A2 ≤ A3 …
9
Bubble Sort Algorithm bubbleSort(A[0..n-1])
//mensorting array A menggunakan bubble sort //input : array A[0..n-1] //output : array A[0..n-1] dalam keadaan terurut naik for i ← 0 to n – 2 do for j ← 0 to n – 2 – i do if A[j + 1] < A[j] swap A[j] and A[j + 1]
10
Bubble Sort Analisalah kompleksitas waktu bubble sort Ө(n2)
11
Brute Force Rarely a source of clever or efficeient algorithm
BUT important algorithm design strategy Applicable to a very wide variety of problems Yields reasonable algorithms of at least some practical value with no limitation of instance size Expense of designing a more efficient algorithm may be unjustifiable if only a new instances of a problem need to be solved and a brute force algorithm can solve those instances with acceptable speed
12
Tugas Tugas untuk pertemuan 7 dapat didownload di mariefh.lecture.ub.ac.id Dipresentasikan oleh mahasiswa dengan nomor_urut_absen % 10 == 2
Presentasi serupa
© 2024 SlidePlayer.info Inc.
All rights reserved.