1 / 12

Dasar – dasar Pemrograman

Dasar – dasar Pemrograman. Pertemuan 2 Sorting. Pengantar. Sorting adalah proses penyusunan elemen – elemen dengan tata urut tertentu . Metode – metode sorting: Bubble Sort Insertion Sort Selection Sort Quick Sort dll. Bubble Sort. Merupakan metode yang paling mudah .

Télécharger la présentation

Dasar – dasar Pemrograman

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. Dasar – dasarPemrograman Pertemuan 2 Sorting

  2. Pengantar • Sorting adalahprosespenyusunanelemen – elemendengantatauruttertentu. • Metode – metode sorting: • Bubble Sort • Insertion Sort • Selection Sort • Quick Sort • dll..

  3. Bubble Sort • Merupakanmetode yang paling mudah. • Bubble sort mengurutkan data denganmembandingkanelemensekarangdenganelemenberikutnya.

  4. Bubble Sort • Contohklip

  5. Bubble Sort Pseudocode fori = n to 1 for j = 0 to i-1 if A[j] < A[j+1] swap(A[j],A[j+1])

  6. Contoh program Bubble Sort

  7. Insertion Sort • Salahsatualgoritmapengurutan yang sederhana. • Miripdengan bubble sort, tapi insertion sort akanterusmembandingkansatuelemensampaiselesaiberadapadatempat yang telahterurut.

  8. Insertion Sort • Contohklip

  9. Insertion Sort Pseudocode fori = 1 to n-1 j = i while j > 0 AND A[j] < A[j-1] swap(A[j],A[j+1]) j = j-1

  10. Contoh program Insertion Sort

  11. Latihan • Buatlah program yang dapatmengurutkanhurufsecaraalfabetisdaria-z denganmenggunakanmetode bubble sort atau insertion sortdarisebuahkalimat yang diberikanolehpengguna.

  12. Tugas • Buatlah program yang dapatmengurutkannama - namasecaraalfabetisdari a-z darimasukkan yang diberikanolehpenggunamenggunakanmetode bubble sort dan insertion sort. Input: Heru Joko Budi Acok Andika Output: Acok Andika Budi Joko Heru

More Related