Category Archives: Sorting

Insertion Sort

Insertion Sort In Insertion Sort, we grow the sorted array one element at a time. The array is divided into two parts, sorted part and unsorted part, sorted part being the part we have already traversed i. e. to the left of current index. At this point, it’d be well to mention that a single number… Read More »

Bubble Sort

Bubble Sort Bubble Sort (for ascending order) can be seen as the following steps: Algorithm for Bubble Sort: Traverse the given array n = size of array times. Compare adjacent elements of the array. If they are in the wrong order i.e. in descending order then swap them as we want the elements to be in… Read More »

Selection Sort

Selection Sort Selection Sort (for sorting in ascending order) can be seen as the following steps: Algorithm for Selection sort: Find the smallest element in the array. Put the element at the beginning of the array. Continue the steps 1 and 2 by incrementing the starting point in each iteration. The array is divided into… Read More »