Elementary sorting and Selection sort for data structure in 'C'

March 23, 2014 0 Comments

Elementary sorting:

            As we have seen in the case of binary search that it is necessary to arrange the elements of the array in a particular order either in ascending or in descending order. So if the elements of the array are arranged in either ascending or descending order then such array is called as sorted array. The operation necessary to apply on the array to arrange the elements of the same in order is called as sorting. If the array elements are not stored order then we apply sorting operation to sort the array elements. the elementary sorting techniques that are used are Selection sort, Insertion sort, and bubble sort. Basically the sorting operation is applied to sort the elements in ascending order. Let us study the techniques to sort the elements of one-dimensional array in ascending order.

  Selection sort:

           In this technique of sorting, the fact of selecting the minimum element from n (size of the array) number of elements is used. The selected minimum element is interchanged with the first element of the array. Then leaving the first element, the minimum element is again picked from the remaining n-1 elements and interchanged with the second element. The same process of selecting minimum element and interchanging it from the respective element is repeated to obtain the sorted array. In total n-1 passes are applied to obtain the sorted array. As we select the minimum element in every pass this technique of sorting the elements is called as Selection sort. 

Jackrin Reacher

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google