Data Structures & AlgorithmsHardICPC regional · GATE CS

Problem: On the 4-cycle C4 (vertices 0-1-2-3-0), a walker starts at 0 and takes exactly 3 steps, each to an adjacent vertex. How many walks of length 3 end at vertex 0?

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

Correct answer: B. 0

C4 is bipartite, so every walk of odd length ends on the opposite colour class from its start. Vertex 0 is in the same class as the start only for walks of even length, so the count is zero.

More Coding Interview Problems questions

Exams that ask this topic