A Hamiltonian Cycle of an undirected graph G = (V, E) is a simple cycle that contains each vertex in V.
Hamiltonian Cycle Decision Problem: Does a graph G have a Hamiltonian Cycle?
Language: HAM-CYCLE = {G G contains a Hamiltonian Cycle}
Naive Solution: Try all possible cycles.
If encode graph as an adjacency matrix and n = G , then the number of vertices m in G is . There are m! permutations of vertices (possible cycles); thus, running time is = = , which is O(nk) for any constant k.
In fact, HAM-CYCLE is NP-Complete.