Comparison of Sorting Algorithms
Discuss the comparison between bubble, selection, and insertion sorting algorithms.
We'll cover the following
Comparison of sorting algorithms
Bubble sort
This sort is usually taught as an introductory exercise for understanding arrays and practicing array manipulations. There is one particular case in which bubble sort is preferred. Imagine a scenario where the data is stored in the tape drive, where moving forward is extremely easy and fast but rewinding is extremely difficult; along with that, processing only two neighbors is allowed. In such a scenario, the bubble sort is perhaps the optimal sorting algorithm to be used.
Selection sort
The selection sort is usually not very useful because it will always go for the range minimum search even if the value on the required index is already placed. The only good thing perhaps is that in terms of values swapped, selection sort takes a maximum of size-1
swaps.
Insertion sort
On small data or especially when the data is partially sorted, the insertion sort beats almost all the sorting algorithms.