Exercise Lover

June 27, 2007

Exercises 23.2-8

Filed under: 23.2 — yuhanlyu @ 3:44 am

The algorithm fails on G=(V,E), V={1,2,3,4}, E={(1,2),(1,3),(2,4),(3,4)} which weight is {1,2,3,4}. If V_1 = {1,2}, V_2 = {3,4}, the minimum spanning tree of {3,4} is edge (3,4) which is not in minimum spanning of G.

Exercises 23.2-7

Filed under: 23.2 — yuhanlyu @ 3:41 am

Let node u be the new vertex, and E’ be the incident edges. The minimum spanning tree for G=(V+u, T+E’) is the solution. Since T+E’ is O(V), using the Prim’s algorithm with Fibonacci heap, it can be done in O(V lgV) time.

Exercises 23.2-6

Filed under: 23.2 — yuhanlyu @ 3:37 am

Kruskal algorithm is faster, since we can use the bucket sort.

Exercises 23.2-5

Filed under: 23.2 — yuhanlyu @ 3:37 am

If the weight is bounded by W, we can use the array to implement priority queue. Hence the EXTRACT-MIN can be done in O(W)=O(1) time. Then the total running time is O(E).

If the weight is bounded by V, this situation is complicated. Using van Emde Boas data structure, or redistributive heap may help.

Exercises 23.2-4

Filed under: 23.2 — yuhanlyu @ 3:29 am

O(Eα(V)), since we can sort in linear time.

Exercises 23.2-3

Filed under: 23.2 — yuhanlyu @ 3:28 am
E=Θ(V) E=\Theta(V^2)
Binary Heap V lgV V^2 \lg V
Fibonacci Heap V lgV V^2

Exercises 23.2-2

Filed under: 23.2 — yuhanlyu @ 3:22 am

Use array to maintain the priority queue. The operation EXTRACT-MIN will be in O(n) time.

Exercises 23.2-1

Filed under: 23.2 — yuhanlyu @ 3:20 am

If edge e is in T, then let e be the smallest edge among all edges which weights are equal to e.

Blog at WordPress.com.