home Home
sort Sorts
Bubble Sort Selection Sort Insertion Sort Counting Sort
SORTING VISUALIZER

Sorting Algorithms

In computer science, a Sorting algorithm is an algorithm that puts a random set of numbers into an ascending or decending sequence. A Sorting algorithm that puts the numbers in an ascending sequence is most widely used.

Sorting Algoritms are widely used in many other tasks such as searching, merging, Data Parsing, etc.
For eg:- Binary Search which is a well known searching algorithm that runs in O(logn) time needs the data to be sorted in increasing order.

There are many different sorting algorithms, each with its own specific unique intuition and implementation. They are classified according to two metrics: space complexity and time complexity.

Those two kinds of complexity are represented with asymptotic notations, mainly with the symbols O, Θ, Ω, representing respectively the upper bound, the tight bound, and the lower bound of the algorithm's complexity, specifying in brackets an expression in terms of n, the number of the elements of the data sequence.

Most of them fall into following categories:

  • Logarithmic
    The complexity is proportional to the binary logarithm (i.e to the base 2) of n.
    An example of a logarithmic sorting algorithm is Quick sort, with space and time complexity O(n × log n).
  • Quadratic
    The complexity is proportional to the square of n.
    An example of a quadratic sorting algorithm is Bubble sort, with a time complexity of O(n2).
  • Linear
    The complexity approaches to linear time of n.
    An example of linear sorting algorithm is Counting Sort, with time complexity of O(n+k).

Space and time complexity can also be further subdivided into 3 different cases: best case, average case and worst case.

Some Sorting algorithms are easy to understand while some cause havoc in one's mind. While it's not easy to learn everything and it’s not a good recommendation to learn a piece of code, so here we are with a fun way of understanding the sorting algorithms with visual depiction of prominent ones. So, Let’s get into it....