




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 exam paper are: Advanced Data Structures, Prim's Algorithm, Worst-Case Analysis, Changekey Procedure, Weighted Graph, Edge Weights, Round-Robin Algorithm, Partition Data Structure, Minimum Spanning Tree Algorithm, Findmax Operation
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Be neat and concise, but complete.
Exam 1
Jonathan Turner 9/29/
firstedge a 5
b 3
c
d 9
e
f 10
edges
a
l
3
lnext
9
rnext
e
r
7
wt 1
(^2) d 0 1 7
(^34 68) a
(^4) c 7 3 0
(^51 32) d
(^6) c 0 1 0
(^7) c 6 8 0 f
(^80 14) c
e 10 6 5
2 2 6 e
9
10
firstedge a 5
b 3
c
d 9
e
f 10
edges
a
l
3
lnext
9
rnext
e
r
7
wt 1
(^2) d 0 1 7
(^34 68) a
(^4) c 7 3 0
(^51 32) d
(^6) c 0 1 0
(^7) c 6 8 0 f
(^80 14) c
e 10 6 5
2 2 6 e
9
10
procedure minspantree( graph G , set tree_edges ); vertex u , v ; set tree_vertices ; heap S ; tree_vertices := {1}; tree_edges := {}; for {1, v } ∈ edges(1) ⇒ insert({1, v }, cost (1, v ), S ); rof ; do S ≠ {} ⇒ { u , v } := deletemin( S ); // assume u ∈ tree_vertices tree_vertices := tree_vertices ∪ { v }; tree_edges := tree_edges ∪ { u,v }; for { v,w } ∈ edges ( v ) ⇒ if w ∈ tree_vertices ⇒ delete({ v,w }, S ); | w ∉ tree_vertices ⇒ insert({ v,w }, cost ( v,w ), S ); fi; rof ; od ; end ;
Explain why this algorithm is an instance of the general greedy method.
Give an expression for the time required by all the deletemin operations, in terms of the number of vertices ( n ), the number of edges ( m ) and the heap parameter ( d ). Similarly, give an expression for the time required by all the insert operations and all the delete operations.
What choice of d gives the best overall running time? Why?
.
An alternative way implement a min-max heap is to store the items in two separate d -heaps, one of which is organized to support the findmin operation and the other organized to implement the findmax operation. How does the space used in these two implementations compare? Assume that the min-max heap is not required to provide a general delete operation or a changkey operatiion, but is required to implement both deletemin and deletemax.
Give an asymptotic upper bound on the running time of the changekey operation on this alternate implementation of the min-max heap, in the case when the key increases in value. Also, give an upper bound on its running time when the key decreases in value. How is the running time affected by the value of d used in the underlying d -heaps? What is the best choice for d. Justify your answers.
Give an asymptotic upper bound on the running time of the insert operation. How is the running time affected by the value of d used in the underlying d -heaps? What is the best choice for d from the perspective of the insert operation? Justify your answers.
Assuming that the credit and debit variables used in the original analysis are defined and assigned values in the same way as in the original analysis, give a tight upper bound on the value for fcredit after m operations have been done. Justify your answer.
Suppose that debit (x) is incremented during a find operation and that level (x)= i before the find. If p ( x ) =w before the find and p ( x )= z after the find , how does the value of r ( z ) compare to r ( w )? Explain.
How many times can debit ( x ) be incremented while level ( x )= i? Why?
Give an upper bound on the final value of debit ( x ). Explain.