Sedikit Catatan Tentang Sorting Algorithm

Sorting algorithm adalah sebuah algoritma untuk menyortir elemen yang ada pada sebuah urutan acak untuk menghasilkan urutan yang pasti. Singkat kata, sorting algorithm mengurutkan suatu urutan yang masih acak.

Ada beberapa Sorting algortihm, yaitu :

Bubble Sort

Mengurutkan dengan cara membandingkan dua urutan pertama, lalu urutan yang lebih kecil dipindahkan ke kanan. Begitu seterusnya hingga semua elemen terurut.

Insertion Sort

Start with a sorted list of 1 element on the left, and N-1 unsorted items on the right. Take the first unsorted item (element #2) and insert it into the sorted list, moving elements as necessary. We now have a sorted list of size 2, and N -2 unsorted elements. Repeat for all elements.

Selection Sort

Menyisir semua elemen dan menemukan yang paling kecil. Kemudian di tukar ke posisi pertama.

Merge Sort 

Merge sort takes advantage of the ease of merging already sorted lists into a new sorted list. It starts by comparing every two elements (i.e., 1 with 2, then 3 with 4...) and swapping them if the first should come after the second. It then merges each of the resulting lists of two into lists of four, then merges those lists of four, and so on; until at last two lists are merged into the final sorted list.[16] Of the algorithms described here, this is the first that scales well to very large lists, because its worst-case running time is O(n log n). It is also easily applied to lists, not only arrays, as it only requires sequential access, not random access. However, it has additional O(n) space complexity, and involves a large number of copies in simple implementations.


Comments

Popular posts from this blog

Cara Bikin Blog di blogger.com

Apa itu Boilerplate?

Pengertian Scripting dan Compiled Language