Data Structures & AlgorithmsHardCodeforces Div 2 · ICPC regional

Undirected graph on vertices A, B, C, D, E, F with edges A–B (1), A–E (1), B–C (1), B–D (1), B–E (1), B–F (1), C–D (1), D–E (1) (weights ignored). Vertices are coloured in the order A, B, C, … each with the smallest-numbered colour (0, 1, 2, …) not used by an already coloured neighbour. How many colours does this greedy colouring use?

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

Correct answer: B. 4

Greedy colouring in this vertex order uses 4 colours, while the chromatic number is 3. Confusing the order-dependent greedy result with the optimal value is the mistake.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic