Skip to content
Official PYQ · 2006

GATE CS 2006 Q31 — Regular and Context-free Languages

Explain with AI

Let SHAM3_3 be the problem of finding a Hamiltonian cycle in a graph G=(V,E)G=(V,E)  with ∣V∣|V|  divisible by 33 and DHAM3_3  be the problem of determining if a Hamiltonian cycle exists in such graphs. Which one of the following is true? 

Choose one option
View worked solution

Answer: A

To determine the complexity of DHAM3\text{DHAM}_3 and SHAM3\text{SHAM}_3, we can relate them to the standard Hamiltonian Cycle (HC) problem, which is known to be NP-complete.

1. Analyzing DHAM3\text{DHAM}_3 (Decision Version)

We can show that the standard Hamiltonian Cycle problem reduces to DHAM3\text{DHAM}_3 in polynomial time (HC≤PDHAM3HC \le_P \text{DHAM}_3):

  • Given an arbitrary graph G=(V,E)G = (V, E), we construct a new graph G′=(V′,E′)G' = (V', E') by replacing each vertex v∈Vv \in V with a path of 33 vertices: v1−v2−v3v_1 - v_2 - v_3.
  • For every edge (u,v)∈E(u, v) \in E, we add edges in G′G' connecting the endpoints of their respective paths (e.g., (u3,v1)(u_3, v_1) and (v3,u1)(v_3, u_1)).
  • The number of vertices in G′G' is ∣V′∣=3∣V∣|V'| = 3|V|, which is guaranteed to be divisible by 33.
  • Any Hamiltonian cycle in G′G' must traverse the vertices of each gadget v1−v2−v3v_1 - v_2 - v_3 consecutively. Thus, G′G' contains a Hamiltonian cycle if and only if GG contains a Hamiltonian cycle.

Since this reduction is polynomial-time, and the general Hamiltonian Cycle problem is NP-complete, the restricted decision problem DHAM3\text{DHAM}_3 is NP-hard.

2. Analyzing SHAM3\text{SHAM}_3 (Search Version)

The search version of a problem is always at least as hard as its decision version. If we had a polynomial-time algorithm to find a Hamiltonian cycle (SHAM3\text{SHAM}_3), we could use it to decide if one exists (DHAM3\text{DHAM}_3) in polynomial time.

Since DHAM3\text{DHAM}_3 is NP-hard, the search problem SHAM3\text{SHAM}_3 must also be NP-hard.

Therefore, both DHAM3\text{DHAM}_3 and SHAM3\text{SHAM}_3 are NP-hard.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions