Merge sort

Merge sort is a divide and conquer algorithm. It is a fast, general purpose sorting algorithm.

Time complexity:

Average case : O(n log n)

Best case : O(n log n)

Worst case : O(n log n)

Worst case space complexity : O(n)

[Read More]

Insertion sort

Insertion sort is an in-place sorting algorithm which builds the sorted list one item at a time.

Time complexity :

Average case : O(n2)

Best case : O(n)

Worst case : O(n2)

Worst case space complexity : O(n)

[Read More]

Selection sort

Selection sort is an in-place sorting algorithm.

Time complexity :

Average case : O(n2)

Best case : O(n2)

Worst case : O(n2)

Worst case space complexity : O(n)

[Read More]

Quicksort

Quicksort is a divide and conquer algorithm. Quicksort first divides a large array into two smaller sub-arrays: the low elements and the high elements can then recursively sorts the sub-arrays.

Quicksort is considered to one of the fastest general purpose sorting algorithms even today.

Time complexity:

Average case : n log n

Best case : n log n with simple partition

Worst case : n2

[Read More]

Bubblesort

Bubble sort is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Time complexity:

Average case : n2

Worst case : n2

Best case : n

[Read More]