Could someone explain the difference between polynomial-time, non-polynomial-time, and exponential-time algorithms?
For example, if an algorithm takes O(n^2) time, then which category is it in?
Polynomial Function: A single term or the sum of two or more terms containing variables with positive whole-number exponents. You cannot have a variable in the denominator (this means that you can't divide by x). Exponential Function: This type of function has an x as the exponent.
In general a polynomial algorithm will be considered to be more efficient than an exponential algorithm.
An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm, that is, T(n) = O(nk) for some positive constant k.
noun. An amount of time expressible as an exponential whose exponent is an increasing function of the size of a given problem whose solution is required.
Below are some common Big-O functions while analyzing algorithms.
(n = size of input, c = some constant)
Here is the model graph representing Big-O complexity of some functions
cheers :-)
graph credits http://bigocheatsheet.com/
Check this out.
Exponential is worse than polynomial.
O(n^2) falls into the quadratic category, which is a type of polynomial (the special case of the exponent being equal to 2) and better than exponential.
Exponential is much worse than polynomial. Look at how the functions grow
n = 10 | 100 | 1000 n^2 = 100 | 10000 | 1000000 k^n = k^10 | k^100 | k^1000
k^1000 is exceptionally huge unless k is smaller than something like 1.1. Like, something like every particle in the universe would have to do 100 billion billion billion operations per second for trillions of billions of billions of years to get that done.
I didn't calculate it out, but ITS THAT BIG.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With