1 / 11

SORTING (PENGURUTAN)

SORTING (PENGURUTAN). SORTING (PENGURUTAN). Sorting adalah proses mengatur sekumpulan objek menurut aturan atau susunan tertentu . Urutan objek tersebut dapat menaik (ascending = dari data kecil ke data lebih besar ) atau

Download Presentation

SORTING (PENGURUTAN)

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. SORTING (PENGURUTAN)

  2. SORTING (PENGURUTAN) Sortingadalah proses mengatursekumpulanobjekmenurutaturanataususunantertentu. Urutanobjektersebutdapat menaik(ascending = dari data kecilke data lebihbesar) atau menurun(descending = dari data besarke data lebihkecil).

  3. Algoritmapengurutan (sorting) : • Bubble sort (gelembung) • Selection sort (maksimum/minimun) • Insertion sort (sisip) • Heap sort • Shell sort • Quick sort • Merge sort • Radix sort • Tree sort

  4. Bubble sort (gelembung) Metodepengurutangelembung (bubble sort) diinspirasiolehgelembungsabun yang ada di permukaan air. Karenaberatjenisgelembungsabunlebihringandaripadaberatjenis air makagelembungsabunakanselalumengapung. Prinsippengapunganinijugadipakaipadapengurutangelembung. Elemen yang berharga paling kecil “diapungkan”, artinyadiangkatkeatas (ataukeujung paling kiri) melaluipertukaran.

  5. ContohBubble sort 6 buahelemendibawahiniakandiurutkanmenaik (ascending) Hasilakhirlangkah 1 :

  6. Hasilakhirlangkah2 :

  7. Hasilakhirlangkah3 :

  8. Hasilakhirlangkah 4:

  9. Hasilakhirlangkah5 : Selesai. Lariksudahterurutkan !

  10. Contohprogram bubble sort ascending #include <stdio.h> #include <conio.h> #include <iostream.h> main(){ inti,k,temp; int L[5]; //Jumlahelemendalam array ada 5 L[0]=1; L[1]=50; L[2]=10; L[3]=3; L[4]=2; //Proses secara Ascending(naik) for(i=0;i<=4;i++) for(k=4;k>=0;k--) if (L[k]<L[k-1]) {temp=L[k]; L[k]=L[k-1]; L[k-1]=temp; } for(i=0;i<=4;i++) cout<<L[i]<<endl; getch();}

  11. Kerjakan!! Urutkan 5 buahnilai di bawahinisecara ascending denganmenggunakanalgoritma bubble sort. 9 7 6 3 8

More Related