GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many strings of length 8 over {a, b, c} have no two adjacent equal symbols and also have first symbol ≠ last symbol?

  1. A. 384
  2. B. 320
  3. C. 264
  4. D. 258

Correct answer: D. 258

These are proper 3-colourings of the cycle C₈: (k−1)ⁿ + (−1)ⁿ(k−1) = 2⁸ + 2 = 258. Ignoring the wrap-around condition gives 3·2⁷ = 384.

More Theory of Computation questions

Exams that ask this topic