Loading, please wait...

Complexity

Complexity analysis of Sorting Algorithm

Algorithm

Best time complexity

Average time Complexity

Worst time Complexity

Worst Space Complexity

Bubble sort

O(n)

O(n2)

O(n2)

O(1)

Selection sort

O(n2)

O(n2)

O(n2)

O(1)

Quick sort

O(nlogn)

O(nlogn)

O(n2)

O(nlogn)

Insertion sort

O(n)

O(n2)

O(n2)

O(1)

Radix sort

O(nk)

O(nk)

O(nk)

O(n+k)

Merge sort

O(nlogn)

O(nlogn)

O(nlogn)

O(n)

Shell sort

O(n)

O((nlog(n)2)

O((nlog(n)2)

O(1)

Heap sort

O(nlogn)

O(nlogn)

O(nlogn)

O(n)