/* Bubble Sort */
Bubble sort is a comparison based sorting algorithm wherein comparing adjacent elements is a primitive operation. In each pass, it compares the adjacent elements in the array and exchanges those that are not in order. Basically, each pass through the array places the next largest value in its proper place, hence the number of comparisons reduces by one at each pass. In other words, each item “bubbles”up to the location where it is supposed to be in the sorted sequence. This invariant is maintained by the algorithm in each pass and hence, bubble sort correctly outputs the sorted sequence. For an n-element array, the below pseudocode requires n − i comparisons for the i th iteration (Pass).
Written with ♥ from Mangesh.
|1||C program sort array using Bubble Sort technique.|
|2||C program for sorting an array using Insertion Sort technique.|
|3||C program to sort an array using Selection Sort technique.|