Exercise Lover

June 30, 2007

Problems 24-6

Filed under: Problem 24 — yuhanlyu @ 2:14 pm

If all shortest paths are monotonically increasing, we can sort all edges and relax it in increasing order. If all shortest paths are increasing then decreasing,  we can sort all edges and relax it in increasing order then relax it in decreasing order.

Extending this idea, the bitonic shortest paths have two situations, one is increasing – decreasing – increasing, another is decreasing – increasing – decreasing. We can sort all edges first, then according two different case relax three times. After combing these two possible solutions, we can get the optimal solution. The time complexity is O(|E| lg |E|).

Problems 24-5

Filed under: Problem 24 — yuhanlyu @ 2:12 pm

a. If G contains a negative-weight cycle, then μ* will be negative and the shortest path may decrease by going through this cycle.

b.If μ* =0, then there is no negative cycle in G and the length of shortest path < n.  Because n – k > 0, and the numerator is \delta_n(s,v)\delta(s,v) ≥0.

c. We know that \delta(s,v) \leq \delta(s,u) + x and \delta(s,u) \leq \delta(s,v) -x because the shortest path property.

d. We can go to the minimum mean-weight cycle by shortest path and travel on the cycle until the length is n ending in vertex v. Since we use the shortest path and μ* =0, there is no shorter path to reach v. Combine the result of b, we can get the answer.

e. By d, this is obvious.

f. If every edge increase by t, the \delta_n(s,v) will increase nt and \delta_k(s,v) will decrease kt.

g. Compute the \delta_k(s,v) for all v and find the min-max value.

Problems 24-4

Filed under: Problem 24 — yuhanlyu @ 2:11 pm

a. Use the Dijkstra algorithm with special priority queue which is implemented by array with size |E|.

b. Since \delta_1(u,v) \leq 1, the shortest path is smaller than |E|. We can use the result of a.

c. Because all edges are multiply by two and add one or zero. The shortest path will at least become two times larger and plus some constant C. 0 ≤ C < |V|.

d. w'_i(u,v) = w_i(u,v) + 2\delta_{i-1}(s,u) - 2\delta_{i-1}(s,v) \geq 2w_{i-1}{u,v} +  2\delta_{i-1}(s,u) - 2\delta_{i-1}(s,v) ≥ 0.

e. For any path P from u to v, w'_i(P) = w_i(P) + 2\delta_{i-1}(s,u) - 2\delta_{i-1}(s,v) then substitute u by s.

f. If a ~ e is completed, the algorithm is obvious.

Problems 24-3

Filed under: Problem 24 — yuhanlyu @ 2:06 pm

a. If R[i_1, i_2] \times R[i_2,i_3] \times \dots \times R[i_k,i_1] > 1, then R[i_1, i_2]^{-1} \times R[i_2,i_3]^{-1} \times \dots \times R[i_k,i_1]^{-1} < 1, then \lg R[i_1, i_2]^{-1} + \lg R[i_2,i_3]^{-1} + \dots + R[i_k,i_1]^{-1} < 0. We can set the edge weight with lg R[i,j], and find the negative cycle.

b. Same as exercises 24.1-6.

Problems 24-2

Filed under: Problem 24 — yuhanlyu @ 2:01 pm

a.

b. Sort the d-dimension then check.

c. Construct a graph with n vertices. If box i can be nest within another box j, then create a edge from node i to node j. The graph must be DAG, hence the longest path in this graph is the answer.

Problems 24-1

Filed under: Problem 24 — yuhanlyu @ 1:56 pm

a. Because all edges in E_f are from small index to high index, it is impossible to create a cycle.

b. Suppose that there is a shortest path P from s to v with length k. If E_f or E_r contains whole P, we only need to run one pass then we can get the optimal solution. If there are two consecutive edges which are in different part, then it requires a half pass in the new direction of the path to get the optimal solution. Since the k is at most |V| – 1,  the change in direction is not greater than |V| – 2. We can conclude that we need only to run |V|/2 passes.

c. No, the time complexity is O(VE) .

Exercises 24.5-8

Filed under: 24.5 — yuhanlyu @ 1:13 pm

Solution wanted!

Exercises 24.5-7

Filed under: 24.5 — yuhanlyu @ 1:12 pm

We can relax the shortest tree edge in the BFS order.

Exercises 24.5-6

Filed under: 24.5 — yuhanlyu @ 1:09 pm

Solution wanted!

Exercises 24.5-5

Filed under: 24.5 — yuhanlyu @ 1:07 pm

Solution wanted!

Older Posts »

Blog at WordPress.com.