$ L = \{ <G,k> |\ G \ has \ a \ simple \ cycle \ at \ length \ k \} $
I think this language is in NP but my friend thinks this language is in P.
NP proof: if a graph has a simple cycle of a specific length can be verified quickly if we are given the cycle as a certificate.We can check in polynomial time that the given cycle is simple (doesn't repeat vertices except the first and last to make a cycle) and that it has exactly k + 1 edges.
$ R_L = {<G,k >,<C>} $
where C is a cycle of k size in the graph,{qstart,q2....qend} V verifier will:
- take qstart, and follow the next q until reaching qend, if qend and qstart are different then reject. if the cycle has different number of nodes then k, regect. if that is not a simple cycle ( going over the same node twice), then regect
- accept
so $ <G,k > \in L $ then S is a simple cycle and the verifier will accept. and if $ <G,k > \notin L $ then S is not a simple cycle, or the size is not k then will reject.
my friend proof in P: there exists a polynomial deterministic in the size of the input: for each <G,k>:
- run a DFS for each vertex: a. check for a cycle of size k if not exactly k then reject (when running DFS reaching to the same vertex) if there is a simple cycle of size k then accept. b. if all reject then reject.
time complexity $ O((V+E) \cdot V) $ the turning machine is deterministic. and: $ <G,k> \in L $ there exist a cycle size k , the machine will recognize it and return true.
$ <G,k> \notin L $ the machine will not find a cycle of size k and will reject
does my friend approach is correct and the language is in P?