Skip to main content

Big O—Popular Algorithms

Sorting Algorithms

Table below shows the average time complexities for different sorting algorithms. Also, it includes corresponding (worst) space complexities.

AlgorithmAverage TimeWorst Space
Quick SortO(nlogn)O(n \log{n})O(logn)O(\log{n})
Merge SortO(nlogn)O(n \log{n})O(n)O(n)
Tim SortO(nlogn)O(n \log{n})O(n)O(n)
Heap SortO(nlogn)O(n \log{n})O(1)O(1)
Bubble SortO(n2)O(n^2)O(1)O(1)
Insertion SortO(n2))O(n^2))O(1)O(1)
Selection SortO(n2)O(n^2)O(1)O(1)
Tree SortO(nlogn)O(n \log{n})O(n)O(n)
Radix SortO(nk)O(nk)O(n+k)O(n + k)
Counting SortO(n+k)O(n + k)O(k)O(k)

***More will be added.

Searching Algorithms

Table below shows the average time complexities for different sorting algorithms. Also, it includes corresponding (worst) space complexities.

AlgorithmAverage TimeWorst Space
Binary searchO(logn)O(\log{n})O(n)O(n)
Linear searchO(n)O(n)O(n)O(n)
Graph BFSO(v+e)O(v + e)O(v)O(v)
Graph DFSO(v+e)O(v + e)O(v)O(v)
Shortest-path (using min-heap)O(e+vlogv)O(e + v \log{v})O(v)O(v)

***More will be added.

Other Algorithms

Will be updated. Check back later.