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?
- A. Maximum bipartite matching
- B. Matrix power of the adjacency matrix
- C. Minimum spanning tree
- 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
- Problem: What is the purpose of path compression in a union-find structure?
- Problem: Which structure answers 'number of points in a rectangle' queries offline in O(log n) each using sorting and a Fenwick tree?
- Problem: What is the expected depth of a random binary search tree built from n distinct keys?
- Problem: What is the Hamming distance between 1011 and 1101 in binary?
- Problem: Which property must a graph have for Euler's theorem to guarantee an Euler circuit?
- Problem: What is the complexity of computing the number of distinct paths in a DAG with V vertices and E edges by DP?