Brendan Ang

Search

Search IconIcon to open search

P and NP Problems

Last updated Nov 8, 2022 Edit Source

# P and NP Problems

Hard Problems: the best-known algorithm for the problem is expensive in terms of running time.

# Classification of Problems

# Decision vs Optimization

Additionally:

# P Problems

P is the set of all decision problems which can be solved in polynomial time by a deterministic Turing machine.

$P\in NP$ because if a problem is solvable in polynomial time then a solution is also verifiable in polynomial time by simply solving the problem.

# NP Problems

Non-deterministic polynomial time problems.

The class of decision problems for which they are solvable in polynomial time by a nondeterministic algorithm. Equivalently:

What is a nondeterministic algorithm:

Why is the Knapsack Problem in NP? Verification: There are $2^n$ subsets of n objects: to check all subsets we would need $O(2^n)$ time. However, given a guess of a subset: to check this subset we would need $O(n)$ time. Solution: DP Solution is Pseudo-Polynomial Time Complexity

# NP Complete Problems

# NP Hard Problems

“At least as hard as the hardest problems in NP”. NP-Hard problems do not have to be in NP and do not have to be decidable.

A problem D is NP-Hard when for every problem L in NP, there is a polynomial time reduction from L to D. Equivalently:

# Example reductions

Show that the Longest Path Problem is NP-Hard.

Reduction from the Travelling Salesman Problem: For a weighted complete graph G with non negative weights, the path that passes through all the vertices once must also be one of the longest paths because the longest path must include all vertices. Forgo the shortest path optimization in TSP and we obtain LPP.

Reduction from the Hamiltonian Path Problem: For an unweighted graph G, it has a Hamiltonian path if and only if its longest path has length n − 1, where n is the number of vertices in G. Because the Hamiltonian path problem is NP-complete, this reduction shows that the decision version of the longest path problem is also NP-complete. In this decision problem, the input is a graph G and a number k; the desired output is “yes” if G contains a path of k or more edges, and no otherwise.

# Too hard…use greedy heuristics