Let G be a directed acyclic graph on n vertices, in which each edge (i, j) has length cij.
State a dynamic programming recursion that calculates the shortest distance from every vertex to a terminal vertex t.
Hints: Let fk(i) denote the length of the shortest path from i to t that contains k or fewer edges, and define fk(·) recursively in terms of fk-1(·).
The boundary conditions are f0(i) = ∞ for i ≠ t and f0(t) = 0.