Time complexities of some common Algorithms

Here are some of the Algorithms and their time complexities.

Algorithm Worst Case Best Case
Bubble Sort O(n^2) O(n)
Selection Sort O(n^2) O(n^2)
Insertion Sort O(n^2) O(n)
Merge Sort O(nlogn) O(nlogn)
Quick Sort O(nlogn) (Average case)
Heap Sort O(nlogn) O(nlogn)
Matrix Multiplication Using Dynamic Programming O(n^3)
CYK Algorithm For Parsing O(n^3)
01 Knap-Sack Problem Using Dynamic Programming O(nw), w=weight which can eb sometimes exponential. Hence called as sudo plynomial
Advertisements