Advanced Topic 35 of 51 Theory & Discrete Math
Class P
Problems solvable in polynomial time.
How it works
Class P contains decision problems solvable by a deterministic algorithm in time polynomial in the input size, such as sorting, shortest paths, matching, linear programming and primality testing, which is in P by the AKS algorithm. P is considered the class of efficiently solvable problems, because polynomial functions are closed under composition and tolerate changes between reasonable computational models, which is the basis of the Cobham-Edmonds thesis.
Step-by-step walkthrough
- P holds problems solvable in time n to some constant power.
- Sorting, shortest paths and primality are in P.
- Doubling the input does not make the time explode.
- P is the formal idea of efficient.
Where it is used
Choosing P-time algorithms is the goal in engineering whenever possible, and many core library functions belong here.
Common pitfall
A polynomial algorithm with a large exponent or constant can be impractical, while some exponential algorithms work well in practice for typical instances. Input size matters: an algorithm polynomial in the numeric value, such as unary knapsack, is pseudo-polynomial and not in P by the strict definition. Measure complexity in terms of the number of bits of the input. Use better algorithms before concluding a problem is hard.
Where it fits in the course
Class P is topic 35 of 51 in Theory & Discrete Math, rated Advanced. It follows Complexity Classes. The next topic is Class NP.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Theory & Discrete Math quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Theory & Discrete Math quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Class P?
Where do people use Class P?
What is the most common mistake with Class P?
What should I learn before this topic?
How can I practice it?
Is Class P hard to learn?
How long does it take to learn Class P?
Which topics are related to Class P?
What should I study after Class P?
Related topics
- Complexity Classes (Theory & Discrete Math)
- Class NP (Theory & Discrete Math)
- Rice's Theorem (Theory & Discrete Math)
- NP-Completeness (Theory & Discrete Math)