A scaling algorithm solves a problem by initially considering only the highest-order bit of each relevant input
Question:
In this problem, we examine an algorithm for computing the shortest paths from a single source by scaling edge weights. We are given a directed graph G = (V, E) with nonnegative integer edge weights w. Let W = max (u, ν) E {w (u, ν)}. Our goal is to develop an algorithm that runs in O(E lg W) time. We assume that all vertices are reachable from the source.
The algorithm uncovers the bits in the binary representation of the edge weights one at a time, from the most significant bit to the least significant bit. Specifically, let k = lg (W + 1) be the number of bits in the binary representation of W, and for i = 1, 2, . . . ,k, let wi (u, ν) = w(u, ν)/2k-i. That is, wi (u, ν) is the "scaled-down" version of w (u, ν) given by the i most significant bits of w (u, ν). (Thus, wk(u, ν) = w(u, ν) for all (u, ν) E.) For example, if k = 5 and w(u, ν) = 25, which has the binary representation ©11001ª, then w3(u, ν) = ©110ª = 6. As another example with k = 5, if w(u, ν) = ©00100ª = 4, then w3(u, ν) = ©001ª = 1. Let us define δi (u, ν) as the shortest-path weight from vertex u to vertex ν using weight function wi. Thus, δk (u, ν) = δ(u, ν) for all u, ν V. For a given source vertex s, the scaling algorithm first computes the shortest-path weights δ1 (s, ν) for all ν V, then computes δ2 (s, ν) for all ν V, and so on, until it computes δk (s, ν) for all ν V. We assume throughout that |E| ¤ |V| 1, and we shall see that computing δi from δi-1 takes O(E) time, so that the entire algorithm takes O(kE) = O(E lg W) time.
a. Suppose that for all vertices ν V, we have δ(s, ν) ¤ |E|. Show that we can compute δ(s, ν) for all ν V in O(E) time.
b. Show that we can compute δ1(s, ν) for all ν V in O(E) time.
Let us now focus on computing δi from δi-1.
c. Prove that for i = 2, 3, . . . ,k, we have either wi (u, ν) = 2wi-1 (u, ν) or wi (u, ν) = 2wi-1(u, ν) + 1. Then, prove that
for all ν V.
d. Define for i = 2, 3, . . . ,k and all (u, ν) E,
Prove that for i = 2, 3, . . . ,k and all u, ν V, the "re-weighted" value wÌi (u, ν) of edge (u, ν) is a nonnegative integer.
e. Now, define δÌi (s, ν) as the shortest-path weight from s to ν using the weight function wÌi. Prove that for i = 2, 3, . . . ,k and all ν V,
f. Show how to compute δi (s, ν) from δi-1 (s, ν) for all ν V in O(E) time, and conclude that we can compute δ (s, ν) for all ν V in O(E lg W) time.
Step by Step Answer:
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest