Intermediate Topic 34 of 51 Theory & Discrete Math
Complexity Classes
Groupings of problems by resource requirements.
How it works
Complexity classes group decision problems by the resources needed to solve them on a machine model. Time classes include P, solvable in polynomial time, NP, verifiable in polynomial time, and EXP, exponential time; space classes include L, logarithmic space, and PSPACE, polynomial space. Known inclusions are L within P within NP within PSPACE within EXP, but most are not known to be strict. Classes are defined with respect to worst-case, deterministic or nondeterministic, randomized and quantum models.
Where it is used
Complexity classes guide algorithm design, show which problems to approximate or solve heuristically and underpin cryptography, which assumes certain problems are hard.
Common pitfall
Class membership is about growth rates in asymptotics, not practical speed: an n to the 100 algorithm is in P but unusable. Hardness is for worst cases; average instances may be easy. Confusing NP with not polynomial is a classic misconception: NP means verifiable quickly. Learn the relationships and canonical complete problems for each class.
Where it fits in the course
Complexity Classes is topic 34 of 51 in Theory & Discrete Math, rated Intermediate. It follows Rice's Theorem. The next topic is Class P.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Theory & Discrete Math quiz.
- Explore the Growth Rates (Big-O) visualizer: Chart O(1) to O(n!) as n grows.
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 Complexity Classes?
Where do people use Complexity Classes?
What is the most common mistake with Complexity Classes?
What should I learn before this topic?
How can I practice it?
Is Complexity Classes hard to learn?
How long does it take to learn Complexity Classes?
Which topics are related to Complexity Classes?
What should I study after Complexity Classes?
Related topics
- Rice's Theorem (Theory & Discrete Math)
- Class P (Theory & Discrete Math)
- Reductions (Theory & Discrete Math)
- Class NP (Theory & Discrete Math)
- Time Complexity (Algorithms)
- Space Complexity (Algorithms)
- Classes and Objects (Programming Fundamentals)