GATE / CS ARCHIVE

SUBJECT COLLECTION

Algorithms · Computational Complexity

5 questions, newest first

GATE CSE has asked 5 questions on Computational Complexity (Algorithms) from 1992 to 2013, in 5 of the 46 papers; the most recent is in GATE CSE 2013. In the last five years it carried 0 marks per 100-mark paper on average, against 0.1 since 2003.

Not in the GATE 2027 syllabus. Complexity classes (P, NP, NP-complete) and reductions are not named.

Browse topics
1 mark · MCQ
Not in GATE 2027 syllabusReport issue

Cycle detection and complexity classes

Computational Complexity

Question 18, GATE 2013: Which are true?1 Undirected-cycle detection is in P.2 It is in NP.3 Every NP-complete problem has a nondeterministic polynomial-time algorithm. A1, 2, 3; B1, 2; C2, 3; D1, 3.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Undirected-cycle detection is polynomial via DFS or union-find, so it belongs to P and therefore also NP. By definition an NP-complete decision problem belongs to NP and has a nondeterministic polynomial-time algorithm. All three statements are true, A.

DFS detects an undirected cycle in O(V+E) time by finding an already visited neighbor other than the parent, so the first claim is polynomial. Every deterministic polynomial computation is also an allowed nondeterministic polynomial computation, giving P⊆NP and claim 2. NP-completeness includes membership in NP in its definition, not only NP-hardness, so claim 3 follows. No assumption that P≠NP is needed for any of these conclusions.

Original paper, page 4 · Answer key

1 mark · MCQ
Not in GATE 2027 syllabusReport issue

NP-hardness within NP

Computational Complexity

Question 14, GATE 2009: Problem π belongs to NP. Which assertion follows? A no polynomial algorithm exists; B a deterministic polynomial algorithm for π would imply P=NP; C if π is NP-hard then it is NP-complete; D π may be undecidable.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

A problem already in NP is NP-complete exactly when it is also NP-hard, so C. Membership in NP does not exclude membership in P, and solving an arbitrary NP problem efficiently would not by itself prove P=NP. Every NP decision problem is decidable.

NP-complete means both membership in NP and NP-hardness. Since membership is given, adding NP-hardness proves C directly. NP also contains easy problems in P, so a polynomial algorithm for an arbitrary member does not settle P versus NP. All NP languages are decidable by finite exhaustive certificate search, ruling out D, and A is not generally true.

Original paper, page 3

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Pseudo-polynomial subset-sum complexity

Computational Complexity

Question 44, GATE 2008: Subset sum asks whether a subset of n positive integers sums to a positive integer W. Algorithm Q takes O(nW) time. Which statement is false?

(A) Q is polynomial-time for unary input encoding
(B) Q is polynomial-time for binary input encoding
(C) Subset sum belongs to NP
(D) Subset sum is NP-hard
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. B is false. The dynamic program takes O(nW), polynomial in the numerical value W, not in its binary encoding length Θ(log W).
2. For binary input W can be exponential in the input length, so this is a pseudo-polynomial algorithm. With unary encoding the input has length at least W and at least n, hence nW is polynomial in that length.
3. A subset is a polynomial-size certificate whose sum can be checked in polynomial time, so subset sum is in NP; its standard decision form is NP-complete and therefore NP-hard. Thus A, C and D are true.

Original paper, page 8

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Fixed-size independent-set decision problems

Computational Complexity

Question 58, GATE 2005: Two undirected-graph decision problems: α asks for an independent set of size |V|−4; β asks for an independent set of size 5. A α in P, β NP-complete; B α NP-complete, β in P; C both NP-complete; D both in P. The source says independent set, not clique, for β.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

For α, an independent set of |V|−4 vertices exists exactly when some four-vertex complement covers all edges (handle |V|<4 separately). Enumerate O(n4) complements and check the remaining edges. For β, enumerate O(n5) five-vertex subsets and test that all ten vertex pairs are nonedges. Both are polynomial-time because 4 and 5 are constants, so D.

An independent set leaves no edge with both endpoints inside it. For α, enumerate every possible four-vertex excluded set and test the remaining induced graph for an edge; O(n⁴(n+m)) is polynomial. For β, enumerate every five-vertex set and test its ten pairs for the absence of edges; O(n⁵) suffices with adjacency lookup. Unlike the NP-complete general independent-set problem, the relevant size or complement size here is a fixed constant, not part of the input. Hence both are in P.

Original paper, page 7

Not in GATE 2027 syllabusReport issue

A polynomial graph problem among hard problems

Computational Complexity

Question 2(vi), GATE 1992: Which is the polynomial-time exception among Hamiltonian circuit, 0/1 knapsack, biconnected components, and graph coloring?
Question 2(vi), GATE 1992: Which is the polynomial-time exception among Hamiltonian circuit, 0/1 knapsack, biconnected components, and graph coloring?
Tap to enlarge
Select all that apply
Answer & solution

Answer: C: biconnected components, under the conventional P≠NP interpretation (no official key was published)

A DFS computes discovery times and low-link values, identifying articulation points and biconnected components in O(V+E). General Hamiltonian-cycle and coloring decision variants are NP-complete, and 0/1 knapsack is NP-hard in its optimization form, with NP-complete decision form. Thus C is the standard intended answer to “not NP-hard.” Strictly, proving a nontrivial polynomial decision problem is not NP-hard would require separating P from NP; the classification here uses the conventional complexity distinction rather than claiming that open separation has been proved.

Original paper, page 2