Sorting algorithms explained in simple manner

Sorting is an operation in computer science via which data is being arranged in an ordered sequence. There are lots of efficient algorithms are already present to perform sorting operation which we are going to discuss here.

Some of the most used sorting algorithms are as follows:

1) Bubble Sort
2) Insertion Sort
3) Merge Sort
4) Selection Sort
5) Quick Sort
6) Heap Sort

Comparison of various Sorting algorithms in terms of time complexity for best and worst case:

Sorting Algorithm
Time Complexity
Bubble SortBest Case: O(n) . This occurs when array is already sorted.
Worst Case: O(n*n). This occurs when array is reverse sorted.
Insertion SortBest Case: O(n) . This occurs when array is already sorted.
Worst Case: O(n*n). This occurs when array is reverse sorted.
Selection SortBest and Worst Case: O(n*n). Not dependent on data distribution.
Merge SortBest and Worst Case: O(nLogn). Not dependent on data distribution.
Quick SortBest Case: O(nLogn) . This occurs data distribution is random.
Worst Case: O(n*n). This occurs when array is already sorted.
Heap SortBest and Worst Case: O(nLogn). Not dependent on data distribution.

As we can see, every sorting algorithm has some pros and cons. Hence, for choosing sorting algorithm type of data and size of data needs to be considered. All of these we will discuss in specific search algorithm explanations.

Leave a Reply

Your email address will not be published. Required fields are marked *