Complexity Classes


P

P refers to Polynomial, the complexity class of problems that are deemed to be tractable i.e. solved in worst-case polynomial time of or less. A P-class problem can be verified in polynomial time as well.

A P-Class problem will have the following Big-O time complexities:

  • - Linear
  • - Log
  • - Loglinear
  • - Polynomial

Examples

  • Determining whether a number is prime
  • All searches and sorts
  • Matrix Multiplication
Link to source


NP

NP refers to Non-Deterministic Polynomial, the class of problems that are intractable to solve but can be verified reasonably. These set of problems have a worst-case time that is great than polynomial time i.e.

An NP-Class problem will have the following Big-O time complexities:

Examples

#todo List NP Problems that are neither NP-Complete nor NP-Hard

Link to source


NP-Complete

NP-Complete problems are an intersection of NP and NP-Hard problems. Therefore they must be verifiable in polynomial time (to be in NP) and is at least as hard as the hardest problem in NP (NP-Hard definition). All NP-Complete problems are related, and they can all become the same problem

Examples

Link to source


NP-Hard

NP-Hard is a set of problems that cannot be solved in polynomial time and may or may not be verifiable in polynomial time. If an NP-Hard problem is solved, it can be used to solve every other NP problem.

Examples

Link to source

Resources

P vs. NP and the Computational Complexity Zoo - YouTube