The class \mathcal {P} [00VS]
- December 2, 2026
Definition Polynomial time [00VO]
- December 2, 2026
If there is a polynomial p(n) such that A(s) always terminates in at most p(|s|) steps, we say A is a polynomial-time algorithm.
Definition \mathcal {P} [00VP]
- December 2, 2026
We define \mathcal {P} as the set of decision problems D solvable in polynomial time. That is, D \in \mathcal {P} if there exists some polynomial-time algorithm A which solves D.
Remark \mathcal {P} is problems [00VR]
- December 2, 2026
Note that \mathcal {P} is a set of problems, not a set of algorithms; it is the set of all problems which can be solved by some polynomial-time algorithm. For example, it does not make sense to say that Dijkstra's Algorithm is in \mathcal {P}; but it does make sense to say that the \mathsf {SHORTEST}-\mathsf {PATH} problem is in \mathcal {P}, since it can be solved by Dijkstra's Algorithm (which, as we know, is a polynomial-time algorithm).
Remark Why \mathcal {P}? [00VQ]
- December 2, 2026
Why focus on \mathcal {P}? As mentioned previously, we typically take polynomial-time as our definition of "feasible". There is both a theoretical and a practical reason for this. The theoretical reason is that the set of polynomials is closed under many natural operations. For example, if p(n) and q(n) are polynomials, then p(n) + q(n), p(n)q(n), and even p(q(n)) are all polynomials as well. If we have two algorithms which take time p(n) and q(n) respectively, then p(n) + q(n) represents the time to run the two algorithms in sequence; p(n)q(n) represents the time to run one nested inside the other; and even p(q(n)) corresponds to a natural operation on algorithms which we will encounter shortly. So if we focus on algorithms in \mathcal {P}, we can combine them in many natural ways and still remain in \mathcal {P}.
This would be a bad reason if it were only theoretically nice but did not correspond to reality very well. However, polynomial time corresponds well to what is feasible in practice. Most real polynomial-time algorithms have relatively small exponents; the biggest power I have ever seen in an algorithm which is actually used in practice is n^6. And there are many cases where a small tweak is all that separates a problem from being solvable in something like \Theta (n^2) time to requiring \Theta (2^n) time. That is, problems don't "degrade gracefully" from feasible to infeasible; there often seems to be a sharp divide where problems suddenly jump from having a nice, efficient, polynomial-time solution to having only exponential-time solutions.