NP Complete
NP Complete
Polynomial Time
• Most (but not all) of the algorithms we have studied so far are easy, in
that they can be solved in polynomial time, be it linear, quadratic, cubic,
etc.
• Cubic may not sound very fast, and isn’t when compared to linear, but
compared to exponential we have seen that it has a much better
asymptotic behavior.
• There are many algorithms which are not polynomial. In general, if the
space of possible solutions grows exponentially as n increases, then we
should not hope for a polynomial time algorithm. These are the
exception rather than the rule.
Hard Problems
2
i = 23
2
1 1 3
4 1
3
5 4
4 2
1 2 2 2
2 1
1
Logic Gates 0 1 0
1 1
NOT
1 1
0
OR 1
0 0 1
1
AND
Matching
Free Vertex
Definitions
• Set of vertices
such that they
all connect
to each
other.
K-Cliques
• A K-clique is a set of K nodes with all K(K-1)/2 possible edges between
them
• Given: (G, k)
Question: Does G contain a k-clique?
• BRUTE FORCE:
• Try out all {n choose k} possible locations for the k clique
NP-Complete