1 / 11

Algoritma sorting dasar (lanjutan) Pertemuan 11

Algoritma sorting dasar (lanjutan) Pertemuan 11. Matakuliah : T0456 / Algoritma dan Metode Object Oriented Programming Tahun : 2007. Learning Outcomes. Pada akhir pertemuan ini, diharapkan: Mahasiswa dapat menerapkan algortima sorting dasar dalam program C++. Buku Referensi:

alban
Download Presentation

Algoritma sorting dasar (lanjutan) Pertemuan 11

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. Algoritma sorting dasar (lanjutan)Pertemuan 11 Matakuliah : T0456 / Algoritma dan Metode Object Oriented Programming Tahun : 2007

  2. Learning Outcomes Pada akhir pertemuan ini, diharapkan: Mahasiswa dapat menerapkan algortima sorting dasar dalam program C++. Buku Referensi: • Algorithms in C++, Addison Wesley, 1992. Websites: • http://www.deitel.com 3

  3. Outline Materi • Algoritma selection sort • Algoritma insertion sort • Algoritma bubble sort • Contoh program sorting 4

  4. Insertion sort • Algoritma sorting dengan menyisipkan data yang belum terurut pada posisinya yang sesuai sampai seluruh data terurut. • Pada putaran pertama urutkan 2 data pertama. Pengurutan ini bersifat relatif, artinya kedua data ini belum tentu 2 data terkecil dari seluruh data

  5. Insertion sort (Putaran 1) Temp [0] [1] [2] [3] [4] 52 12 40 48 69 Pindahkan ke Temp 12 52 40 48 69 Banding, geser 12 52 40 48 69 Sisip 12 52 40 48 69

  6. Insertion sort (Putaran 2) Temp [0] [1] [2] [3] [4] 12 52 40 48 69 Pindahkan ke Temp 12 52 40 48 69 Banding Sisip 12 52 40 48 69

  7. Insertion sort (Putaran 3) Temp [0] [1] [2] [3] [4] 12 52 40 48 69 Pindahkan ke Temp 12 52 69 48 40 Banding, geser 12 52 40 48 69 Banding, geser 12 52 69 40 48 Banding Sisip 12 52 69 48 40

  8. Insertion sort (Putaran 4) Temp [0] [1] [2] [3] [4] 12 40 69 48 52 Pindahkan ke Temp 12 40 52 69 48 Banding, geser 12 40 48 69 52 Banding, geser 12 40 52 48 69 Banding Sisip 12 48 52 69 40

  9. Insertion sort Code algoritma: Void Insertion (int* Data, int n){ int i, j, temp; for (i=1; i<n; i++){ temp = Data[i]; for (j=i-1; (j>=0) && (Data[j]>temp); j--) Data[j+1]=Data[j]; Data[j+1]=temp; } }

  10. Diskusi dan Tanya JawabLatihan soal 11

More Related