LearnViz CompSci
Home / Learn / Theory & Discrete Math / Complexity Classes

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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. 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?
Groupings of problems by resource requirements. It belongs to Theory & Discrete Math and is an intermediate-level topic.
Where do people use Complexity Classes?
Complexity classes guide algorithm design, show which problems to approximate or solve heuristically and underpin cryptography, which assumes certain problems are hard.
What is the most common mistake with Complexity Classes?
Class membership is about growth rates in asymptotics, not practical speed: an n to the 100 algorithm is in P but unusable.
What should I learn before this topic?
Start with Rice's Theorem, the topic just before it in Theory & Discrete Math.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Theory & Discrete Math quiz. You can also explore Growth Rates (Big-O) in the Visual Lab.
Is Complexity Classes hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Complexity Classes?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Complexity Classes?
Rice's Theorem, Class P, Reductions are closely connected. The full list is in the related topics section of this page.
What should I study after Complexity Classes?
Continue with Class P, the next topic in Theory & Discrete Math.

Related topics