Thursday, February 10, 2011

1. Selection Sort

The algorithm of selection sort finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. The idea of algorithm is quite simple. Array is imaginary divided into parts – sorted and unsorted. At the beginning, sorted part is empty, while unsorted part contains whole array. At every step, algorithm finds minimal element in the unsorted part and adds it to the end of the sorted part. Algorithm stops when unsorted part becomes empty.

2. Insertion Sort

Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly-sorted lists. The algorithm is almost the same with the selection sort. It has two imaginary parts – sorted part that contains the first or the last element of the array, and unsorted contains the rest element. The algorithm is comparing the element of unsorted part into the elements of the sorted part. The element of the unsorted part is placed in the correct position at the sorted part. The algorithm stops when the unsorted part is empty.

3. Bubble Sort

Bubble sort is a simple sorting algorithm. The algorithm starts at the beginning of the data set. It compares the first two elements, and if the first is greater than the second, then it swaps them. It continues doing this for each pair of adjacent elements to the end of the data set. It then starts again with the first two elements, repeating until no swaps have occurred on the last.

4. Shell Sort

Shell sort improves upon bubble sort and insertion sort by moving out of order elements more than one position at a time. One implementation can be described as arranging the data sequence in a two-dimensional array and then sorting the columns of the array using insertion sort.


Reference: http://www.algolist.net/Algorithms

No comments:

Post a Comment