Over the month, we have been inching towards more efficient sorting techniques. Insertion Sort is yet another Sorting Algorithm which works on the principle of In-place sorting. It is the most efficient Sorting Algorithm for small Lists but not very good when the size becomes increasingly large. You would be surprised to hear that Insertion sort uses Bubble Sort in its complete procedure as well. So let us see and try to understand its basics.
Posts Tagged ‘sorting’
Two weeks ago, I explained to you a basic and easy sorting algorithm which was Selection Sort. Moving onwards, there is yet another basic algorithm by the name of Bubble Sort. It is known as Bubble sort because it brings the small values on the top of the list just like the light bubbles in water tend to come to the surface. Let us see how it works in depth.
In the previous post I elaborated on Quick Sort and its basic principles, recursive technique, how to select the pivot and the comparison of quick sort and bubble sort. Today I shall explain a sample problem step by step and then write a source code for it. As I mentioned, I would be considering the first element of the list as the pivot. Watch for the next paragraphs for step by step procedure and source code.
We left our series of Sorting Algorithms about two months ago. Till then we discussed many in-place sorting algorithms like insertion sort, bubble sort, selection sort and gnome sort. These all were the basic algorithms which were inefficient for sorting large lists. For large amount of data, very advanced sorting algorithms have been developed by the experts and a lot of research is still going on in this area. According to many, the fastest Sorting Algorithm in Computer Science is the Quick Sort Algorithm. I shall explain this brilliant algorithm to you in this article in detail. Afterwards we would together write a source code for that.