GATE / CS ARCHIVE

GATE CSE 2026 SET 1 / QUESTION 55

Two-colorability and traversal cost

Discrete Mathematics · Graph Theory · Full GATE CSE 2026 Set 1 paper

GATE 2026 Set 1, Q55 2 marks · MSQ
Report issue

Graph Theory

Question 55, GATE 2026: An undirected simple graph is 2-colorable if adjacent vertices always receive different values in {0,1}. Assess A it may contain odd cycles; B it may contain even cycles; C the standard optimal adjacency-list test is Θ(|V|+|E|); D that bound is Θ(|E|log|V|).
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Givens and goal

An undirected simple graph is 2-colorable if adjacent vertices always receive different values in {0,1}. Assess A it may contain odd cycles; B it may contain even cycles; C the standard optimal adjacency-list test is Θ(|V|+|E|); D that bound is Θ(|E|log|V|).

Approach

Alternate colors around a cycle and describe a full BFS/DFS coloring test across all components.

Step-by-step solution

1. Along a cycle, a proper two-colouring alternates colours on each successive edge. An odd number of alternations would require the starting vertex to have both colours. Odd cycles are therefore forbidden, making A false.
2. An even cycle can alternate colours consistently. A four-cycle is a direct example, so B is true.
3. Use BFS or DFS from every not-yet-coloured vertex, assign opposite colours across each explored edge, and reject if an edge has equally coloured endpoints. If no conflict occurs, the assignment is a valid two-colouring. Processing all components is essential for disconnected graphs.
4. With adjacency lists, each vertex is visited once and each undirected edge is examined at most twice. This is the standard worst-case Θ(|V|+|E|) traversal bound used by the question, yielding C. No sorting or priority queue is required; the claimed optimal logarithmic-factor bound in D is not the standard bound.

Complexity scope: The stated bound is the conventional full-graph adjacency-list algorithm bound. Particular inputs may be rejected earlier, for example when a conflict is found before traversal finishes.

Algorithm outline: for each uncolored vertex, assign color 0 and start a queue or stack. When traversing u—v, assign an uncolored v the opposite color to u; if v is already colored the same as u, reject. Accept only after every component has been processed. The algorithm need not enumerate cycles explicitly: an inconsistent edge supplies the contradiction automatically. Even-cycle example: vertices around a square can be colored 0,1,0,1 in order.

Original paper, page 43 · Answer key