




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this past exam are: Algorithms, Programs, Implementing, Graph Algorithm, Deletemin Operations, Algorithm, Primary Data Structures, Deletemin Operations, Lowest Asymptoti, Implemented
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!
For m<n 3/2^ , we have m2/3^ <n, so the best choice is the same as for Prim’s algorithm. So I would use d=2+m/n in this case.
For m>n 3/2^ , the running time is O((m+m2/3^ )log (^) d n + m2/3^ d log (^) d n). The asymptotic running time is dominated by the larger of the two terms, so we can minimize it by choosing a value of d that makes the two terms roughly equal. Choosing d=m 1 /^3 will work.
What is the resulting asymptotic running time?
What is the resulting asymptotic running time if you used a Fibonacci heap, instead of a d- heap?
Which type of heap would you choose for this application? Why?
Fibonacci heaps have the best overall asymptotic complexity, but they only have an advantage for m<n log n. On the other hand, they use considerably more space than d-heaps (5 values per stored item vs. 3) and are more complex to implement. So, I would most likely use a d-heap, unless I knew that the input graphs were going to be very sparse and that the running time of the heap operations dominated the overall running time.
Problem Set 2 Solutions
Jonathan Turner Exam 2 - 10/28/
Final Exam Solutions
Jonathan Turner 12/22/
Lemma. Let x be any node in an F-heap. Let y 1 ,... ,y (^) r be the children of x, in order of time in which they were linked to x (earliest to latest). Then, rank(y (^) i) ≥ i−2 for all i.
The inequality in the lemma becomes rank(y (^) i) ≥ i− 3. Since y (^) i had the same rank as x when it became a
when it became a child of x. Since it still is a child of x, it can have lost at most two children since that
Let S (^) k be the smallest possible number of descendants that a node of rank k has, in our modified version of Fibonacci heaps. Give a recursive lower bound on S (^) k. That is, give an inequality of the form S (^) k ≥ f(S 0 ,S 1 ,... , S (^) k− 1 ) where f is some function of the S (^) i’s for i<k.
Clearly S 0 =1, S 1 =2 and S 2 =3. For k>2, we can use the modified lemma to conclude that S (^) k ≥ 3 + S 0 + S 1 +" + Sk − 3. Note that the difference between the bounds for S (^) k and for Sk − 1 is Sk − 3.
Use this to give a lower bound on the smallest number of descendants that a node with rank 7 can have.
Show how the heap content changes after the next iteration.
1
3
2
7
7
4
2
0
f
8
2
4
3
8
(^7 )
3 1
2
2 3
5
4
9
1
3
7
1
3
2
7
7
4
2
0
f
8
2
4
3
8
(^7 )
3 1
2
2 3
5
4
9
1
3
7
int mincost;
if (t == Null) return Null; mincost = dmSum + Dmin(t); if (mincost > costBound) return Null;
int y = search(left(t), costBound, mincost); if (y != Null) return y; if (mincost + Dcost(t) <= costBound) return t; return search(right(t),costBound,mincost); }
Draw a picture of the min-cost flow graph that can be used to find a maximum matching in this graph.
Identify a minimum cost augmenting path in the flow graph. What is its cost? Draw the residual graph that results from saturating this path.
The path s-c-x-t is a minimum cost augmenting path with cost -8.
Identify a minimum cost augmenting path in the residual graph. What is its cost?
The path s-b-x-c-z-t is a minimum cost augmenting path, with cost -5.
What is the matching corresponding to the flow that exists after flow is added to this augmenting path?
{b,x}, {c,z}
− 1 − 3
− 2 − 7
− 6 − 3 − 4
0
0
0
0
0
0
− 8
edge capacities=
− 1 − 3
− 2 − 7
− 6 − 3 − 4
0
0
0
0
0
0
− 8
edge capacities=
What happens when the next edge in the queue is processed by the algorithm? Explain.
Nothing. The edge ae joins two vertices that are contained in the same vertex in the current shrunken graph, so the algorithm just discards this edge.
When the next edge, [i,h] is processed, an augmenting path is found. What is that augmenting path?
i,h,q,p,j,b,g,a,d,e,c,r
b
h
k
d e
a j
c
i
p
r
q
l g
n m s
k l r c
n
b (^) d b g
a
q e p h
j
i
s (^) m
h
k
d e
a j
c
i
p
r
q
l g
n m s
k l r c
n
b (^) d b g
a
q e p h
j
i
s (^) m
h
k
d e
a j
c
i
p
r
q
l g
n m s
k l r c
n
b (^) d b g
a
q e p h
j
b (^) d b g
a
q e p h
j
i
s (^) m