Which of the following statements are TRUE? 1. The problem of determining whether there exists a cycle in an undirected graph is in P. 2. The problem of determining whether there exists a cycle in an undirected graph is in NP. 3. If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.

Which of the following statements are TRUE? 1. The problem of determining whether there exists a cycle in an undirected graph is in P. 2. The problem of determining whether there exists a cycle in an undirected graph is in NP. 3. If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A. Correct Answer 1, 2 and 3

The correct answer is option 1.

Key Points

BFS or DFS can be used to find whether there is a cycle in an undirected graph. For example, see DFS based implementation to detect cycle in an undirected graph. The time complexity is O(V+E) which is polynomial and it is a P problem. Every p problems are NP problem (since P⊂NP). So, statement 1 and statement 2 are true.

[ alt="F1 Raju Madhuri 29.05.2021 D3" src="//storage.googleapis.com/tb-img/production/21/05/F1_Raju_Madhuri_29.05.2021_D3.png" style="width: 220px; height: 136px;">

NP-Complete ⊂ NP, for every NP problem, has a non-deterministic polynomial-time algorithm. Hence statement 3 is true.

Hence the all the statements are correct

Related Questions