Link Search Menu Expand Document

Contents

Time complexity of array sorting algorithms

Algorithm Worst case scenario
Quicksort O(n^2)
Mergesort O(n log(n))
Timsort O(n log(n))
Heapsort O(n log(n))
Bubble Sort O(n^2)
Insertion Sort O(n^2)
Selection Sort O(n^2)
Tree Sort O(n^2)
Shell Sort O(n(log(n))^2)
Bucket Sort O(n^2)
Radix Sort O(nk)
Counting Sort O(n+k)
Cubesort O(n log(n))

Big O complexity chart

time complexity chart

source

Example implementation

To see example algorithms implemented in Java, visit the interview-coding-questions repository