IAE Academy

GATE 2026 CS1 Q.55: solution and answer

GATE 2026 · CS1Q.55 · 2 marks · MSQ

An undirected, unweighted, simple graph is said to be 2-colorable if there exists a function such that for every , .

Which of the following statements about 2-colorable graphs is/are true?

  1. (A)

    If is 2-colorable, then may contain cycles of odd length

  2. (B)

    If is 2-colorable, then may contain cycles of even length

  3. (C)

    An optimal algorithm for testing whether is 2-colorable runs in time , if is represented as an adjacency list

  4. (D)

    An optimal algorithm for testing whether is 2-colorable runs in time , if is represented as an adjacency list

See the question in the paper

Answer and solution

ANSWER

Statements (B) and (C) are true; (A) and (D) are false.

Official answer: B, CSource: Official answer key, GATE 2026 CS1 (IIT Guwahati)

  1. Restate the theorem: a graph is 2-colorable (admits a proper coloring with 2 colors) if and only if it is bipartite, if and only if it contains no cycle of odd length.

  2. Check (A): if contained an odd-length cycle, traversing the cycle and alternating colors 0,1,0,1,... would force the last vertex back to color 0, which is adjacent to the starting vertex also colored 0 — violating on that edge. Hence a 2-colorable graph can never contain an odd cycle, so (A) is false.

  3. Check (B): a 2-colorable graph can contain even-length cycles — for instance (a 4-cycle) admits the coloring around the cycle, which is a valid 2-coloring. So (B) is true.

  4. Check (C): a single BFS or DFS from each uncolored vertex, assigning the opposite color to each newly discovered neighbor and checking every edge for a same-color violation, visits every vertex once and examines every edge a constant number of times, giving time on an adjacency-list representation. Since any correct algorithm must read the whole input (every vertex and edge) at least once, is a lower bound, so this algorithm is optimal. Hence (C) is true.

  5. Check (D): is asymptotically worse than the achievable and optimal bound (whenever ), so it cannot describe an optimal algorithm's running time. Hence (D) is false.

  6. Conclusion: the true statements are (B) and (C).

KEY IDEA

2-colorability of a graph is exactly bipartiteness, and bipartiteness is testable in linear time by a single BFS/DFS coloring pass.

WATCH OUT FOR

Confusing "2-colorable" with "properly colored graphs can have any cycle type" — a bipartite (2-colorable) graph can never contain an odd cycle, since traversing an odd cycle forces two adjacent vertices to receive the same color; students sometimes pick (A) by only checking small examples instead of proving the general impossibility.

From the GATE 2026 CS1 paper. Every question of this paper · Download the full paper · All 28 Graph algorithms questions, with notes

More Graph algorithms questions