Question
Which of the following statements are TRUE?
- The problem of determining whether there exists a cycle in an undirected graph is in P.
- The problem of determining whether there exists a cycle in an undirected graph is in NP.
- If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.
Official answer and solution
- Official answer
- A
- From
- Official GATE 2013 answer key
Solution
Assess graph cycle detection complexity and the relationship between complexity classes P, NP, and NPC.
Evaluate each statement:
-
Statement 1: 'The problem of determining whether there exists a cycle in an undirected graph is in P.'
- True. Using Depth First Search (DFS) or Breadth First Search (BFS), a cycle in an undirected graph can be detected by finding a back-edge in deterministic polynomial time.
-
Statement 2: 'The problem of determining whether there exists a cycle in an undirected graph is in NP.'
- True. Since , any problem that belongs to P is automatically in NP.
-
Statement 3: 'If a problem A is NP-Complete, there exists a non-deterministic polynomial time algorithm to solve A.'
- True. By definition, a problem is NP-complete if it is in NP and every problem in NP polynomial-time reduces to it. Belonging to NP means that there exists a non-deterministic polynomial-time algorithm (or a polynomial-time verifier) to solve it.
Thus, statements 1, 2, and 3 are all TRUE.
Option (A)
Thinking that because a problem is in P, it cannot be in NP, forgetting the fundamental set inclusion .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2013 Computer Science and Information Technology (CS)
- Question
- 18 of 65, printed as CS Q.18
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.