Algorithm: Sorting Algorithms

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-

Basic sorting works fine when we have a small number of inputs. But when the size of the data becomes huge, it starts to show performance issues.
We might need some custom rules to sort data, in many of our use cases.
Using an inefficient algorithm with a huge size data set will cost you more computational power and storage/memory. Which will cost you(or your company) more money in terms of the computation cost.
An inefficient algorithm will take longer to process data, which will impact the user experience and increase latency.

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-

AlgorithmBest 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 Bubble Sort Implementation
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.

Leave a Comment


The reCAPTCHA verification period has expired. Please reload the page.