Data Structures & AlgorithmsHardICPC regional · matrix power

Problem: Which problem asks for the number of ways to walk exactly k steps on a graph from u to v?

  1. A. Maximum bipartite matching
  2. B. Matrix power of the adjacency matrix
  3. C. Minimum spanning tree
  4. D. Convex hull

Correct answer: B. Matrix power of the adjacency matrix

The (u,v) entry of A^k counts walks of length k from u to v.

More Coding Interview Problems questions

Exams that ask this topic