1. Defining the Complexity Classes

The note focuses on Decision Problems (problems with a Yes/No answer) and categorizes them into four primary classes based on how hard they are to solve or verify.

ClassDefinitionKey Characteristics
PPolynomial TimeProblems that can be solved in time. These are considered “efficiently solvable.”
NPNondeterministic Polynomial TimeProblems where a proposed solution can be verified in time. Note: .
NP-HardNP-HardProblems that are at least as hard as the hardest problems in . Every problem in can be reduced to these.
NP-CompleteThe IntersectionProblems that are both in NP and NP-Hard. They are the “hardest” problems in to solve, but easy to verify.

2. Practical Examples

Class P: The Oldest Person Problem

Finding the oldest person in a list of people takes time. Since is a polynomial, this problem is in class P.

Class NP: The Subset Sum Problem

Given a set of integers, find a non-empty subset that adds up to 0.

  • Solving it: There is no known polynomial-time algorithm (finding the subset is hard).

  • Verifying it: If someone gives you a subset, you can simply add the numbers in time to check if they equal 0. Because it’s easy to check, it is in NP.

NP-Complete: Boolean Satisfiability (SAT)

This asks if a set of variables can make a Boolean formula TRUE. It is the foundation of modern encryption.

The “Boolean Satisfiability Problem” (SAT) is the historical “patient zero” of NP-Complete problems. This means it is among the hardest problems in the class NP (Nondeterministic Polynomial time).

While it is simple to verify if a specific assignment of TRUE/FALSE satisfies a formula (like your example), there is currently no known algorithm to find that assignment in polynomial time for any arbitrary, complex formula.


3. The “P vs. NP” Problem

This is one of the greatest unsolved mysteries in Computer Science.

  • If : Anything that can be verified quickly can also be solved quickly. This would imply that for many “hard” problems, an efficient solution exists and we just haven’t found it yet.
  • If : There are problems that are fundamentally harder to solve than they are to verify. This is what most computer scientists believe to be true.

4. Strategies for “Hard” Problems

If you encounter a problem that is -Complete (like the Traveling Salesman Problem), and you cannot simplify it into class P, you generally have two paths:

  1. Small Input Sizes: If is very small, even an or algorithm might finish in a reasonable amount of time.
  2. Heuristics: Develop a polynomial-time “good enough” algorithm. It won’t guarantee the absolute best (optimal) solution, but it will get close enough for practical use.

Summary:

Complexity analysis saves you from wasting “hours, days, or even years” trying to find a perfect solution for a problem that is mathematically proven to be incredibly difficult.