Data Structures & AlgorithmsVery hardCodeforces Div 2 C · GATE CS

An undirected graph has the vertices G, I, R, U, Y and the edges I–U, Y–G, Y–U, G–U, R–U. What is its chromatic number, the least number of colours needed to colour the vertices so that adjacent vertices differ?

  1. A. 4
  2. B. 3
  3. C. 5
  4. D. 2

Correct answer: B. 3

Searching colour counts from 1 upward finds 3 colours suffice and one fewer does not. Greedy colouring in label order uses 3, and the maximum degree bound gives 5; the clique number 3 is only a lower bound.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic