Selection Sort Algorithm

The selection sort is using a combination of searching and sorting. Each unsorted element that has the smallest or largest value is moved to the proper position.

The inner loop (see the example) is used for the selection and this loop is searching for the smallest or largest value.
The outer loop is used for putting that value into its proper position. More »

Posted in Programming Algorithms | 1 Comment

Exchange Sort Algorithm

The exchange sort is almost similar as the bubble sort. In fact some people refer to the exchange sort as just a different bubble sort. (When they see the source they even call it a bubble sort instead of its real name exchange sort.)

The exchange sort compares each element of an array and swap those elements that are not in their proper position,
just like a bubble sort does. The only difference between the two sorting algorithms is the manner in which they compare the elements. More »

Posted in Programming Algorithms | 1 Comment

Bubble Sort Algorithm

The bubble sort gets its name because as array elements are sorted they gradually “bubble” to their proper positions,
like bubbles rising in a glass of soda.

A bubble sort will compare two adjacent element of an array and will swap them if they are out of order.
The compare starts with the first and second element. After that it will compare the second with the third element and so on. The process continues until the end of the list is reached. More »

Posted in Programming Algorithms | 1 Comment