GATE 2013 CS (CS1) – Question 28
Which are true? 1: Undirected cycle detection is in P. 2: Undirected cycle detection is in NP. 3: Every NP-complete problem has a nondeterministic polynomial-time algorithm.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (A) 1,2,3
Explanation
DFS detects an undirected cycle in linear graph time, so the decision problem is in P and therefore also in NP. By definition NP-complete problems belong to NP, which supplies a nondeterministic polynomial-time algorithm. All three statements hold, A.