role-algorithms:computational-complexity
Installation
SKILL.md
Computational Complexity
When to use
- Classifying a problem as P, NP-complete, or NP-hard before choosing an algorithm
- Proving a problem is NP-complete via polynomial-time reduction
- Selecting between exact, approximation, FPT, or heuristic approaches
- Designing approximation algorithms with provable guarantees (PTAS, FPTAS)
- Deciding when randomized algorithms (Las Vegas vs Monte Carlo) are appropriate
- Identifying when a parameter makes an otherwise hard problem tractable (FPT)
Core principles
- Classify before solving — knowing a problem is NP-hard changes the entire strategy
- Reduction direction matters — reduce FROM a known hard problem TO yours to prove hardness
- Approximation ratio is a guarantee, not a hope — an unproven heuristic is not an approximation algorithm
- Small parameter = FPT opportunity — exponential in k is fine when k ≤ 20
- Amplify randomized correctness — repeat Monte Carlo k times to push error below 2^(-k)