Data Structures & AlgorithmsHardGATE CS · Advanced

A graph has the vertices A–G and the edges A–B, A–C, A–D, B–D, B–F, B–G, C–D, C–F, C–G, D–F, E–F. In how many ways can the vertices be coloured with three available colours (red, green, blue, all distinguishable) so that adjacent vertices differ? Not every colour has to be used.

  1. A. 30
  2. B. 8
  3. C. 24
  4. D. 4

Correct answer: C. 24

Brute-force the 3^7 assignments (or use deletion-contraction): exactly 24 proper colourings. Dividing by 3! counts only unlabelled colour classes, and by 3 fixes one vertex's colour.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic