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

One thought on “Time complexities of some common Algorithms

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s