Computational Complexity Classes - Complete Guide
Fundamental Complexity Classes
P (Polynomial Time)
Problems that can be solved in polynomial time by a deterministic Turing machine. These are considered "tractable" or efficiently solvable.
NP (Nondeterministic Polynomial Time)
Examples: Sorting, shortest path, linear programming
Problems whose solutions can be verified in polynomial time. If someone gives you a proposed solution, you can check whether it's correct efficiently.
NP-Hard
Contains P, but may be larger. P vs NP is the million-dollar question.
Problems that are at least as hard as the hardest problems in NP. An NP-hard problem doesn't have to be in NP itself. If you could solve any NP-hard problem efficiently, you could solve all problems in NP efficiently.
NP-Complete
Key: Every NP-complete problem is NP-hard, but not all NP-hard problems are NP-complete.
Problems that are both in NP and NP-hard. These are the hardest problems in NP. They serve as the "gatekeepers" - if any NP-complete problem is in P, then P = NP.
Examples: Boolean satisfiability (SAT), traveling salesman, graph coloring
Important Broader Classes
EXPTIME (Exponential Time)
Problems that can be solved in exponential time (O(2p(n)) for some polynomial p). This class is provably larger than P.
PSPACE
We know P ≠ EXPTIME - there are definitely problems harder than P.
Problems that can be solved with a polynomial amount of memory/space, regardless of time. PSPACE contains all of NP, and is contained in EXPTIME.
co-NP
Many two-player games (like generalized chess) are PSPACE-complete.
The class of problems where the "no" answer can be verified in polynomial time. For example, "is this boolean formula unsatisfiable?" - if it's unsatisfiable, there's a short proof.
We don't know if NP = co-NP, though most believe they're different.
Practical Classification Concepts
Tractable
Problems that are feasible to solve in practice for reasonable input sizes. Formally, this generally means problems in P.
Intractable
In practice: problems we can solve for real-world inputs.
Problems that are not feasible to solve exactly for large inputs. This includes NP-complete, NP-hard, and exponential-time problems.
Unsolvable
In practice: we often use approximations or heuristics.
Problems that cannot be solved by any algorithm, regardless of time or memory constraints.
Examples: Halting problem, determining if two programs are equivalent.
Known Relationships
P ⊆ NP ⊆ PSPACE ⊆ EXPTIME
P ≠ EXPTIME (this is proven - there's definitely a hierarchy)
NP-hard contains all of NP and possibly harder problems
Unsolvable problems exist outside this entire hierarchy
Visual Hierarchy
EXPTIME (definitely harder than P)
PSPACE (polynomial space, possibly more than NP)
NP (easy to verify)
P (easy to solve)
NP-hard overlaps with all of these and extends beyond
No comments:
Post a Comment