Sorting algorithms are used to sort/order a set of data according to a given rule, like- ascending order, descending order, or any other custom rule.
Sorting is really important in the majority of cases, when dealing with any set of data.
Now, why do we need to learn sorting algorithms, even though almost all programming languages have sort function(s) built in?
Because-
NOTE
For a large dataset, we can preprocess it and display the results from that preprocessed data.
But re-processing is not always viable, and we can pre-process for all possible scenarios.
So, it is really important to choose the right sorting algorithm based on the problem use case.
There are lots of algorithms available for sorting. Here is the list of sorting algorithms we have discussed-
Algorithm | Best Case Time Complexity Ω(f(n)) | Average Case Time Complexity Θ(f(n)) | Worst Case Time Complexity O(f(n)) | Space / Memory Complexity | Implementation Details |
---|---|---|---|---|---|
Bubble Sort | ![]() | ||||
Insertion Sort | |||||
Selection Sort | |||||
Merge Sort | |||||
Quick Sort | |||||
Redis Sort | |||||
Heap Sort | |||||
Counting Sort |
NOTE
In large organizations, the sorting algorithms(or any important algorithm) are generally written by academics, who have in-depth knowledge and have specialized knowledge in the field of math and algorithms.
But, we still need to have enough understanding of algorithms, to understand the implementations.