Algorithm Exam: MST, Fibonacci Heaps, Dijkstra's, & Max Flow, Exams of Data Structures and Algorithms

Six exam questions related to various algorithms topics, including minimum spanning trees (prim's algorithm), fibonacci heaps, dijkstra's algorithm, and maximum flow. The questions cover finding siblings in a fibonacci heap, computing second-best next hop vertices, maintaining properties of a balanced binary search tree, and finding augmenting paths in the edmonds-karp algorithm.

Typology: Exams

2012/2013

Uploaded on 03/23/2013

saruy
saruy 🇮🇳

4.5

(120)

130 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
- 1 -
Be neat and concise, but complete.
1. (15 points) State the general greedy method for finding minimum spanning trees. Show
that Prim’s algorithm is a special case of the general greedy method.
CS 541 Algorithms and Programs
Final Exam
Jonathan Turner
12/13/01
pf3
pf4
pf5
pf8

Partial preview of the text

Download Algorithm Exam: MST, Fibonacci Heaps, Dijkstra's, & Max Flow and more Exams Data Structures and Algorithms in PDF only on Docsity!

Be neat and concise, but complete.

  1. (15 points) State the general greedy method for finding minimum spanning trees. Show that Prim’s algorithm is a special case of the general greedy method.

CS 541 – Algorithms and Programs

Final Exam Jonathan Turner 12/13/

  1. (10 points) A printout of a Fibonacci heap is shown below. Each set of values represents the (item number, key and rank). Mark bits that are set are shown as an asterisk. 5 1 0 7 2 2 3 6 1 12 19 0 11 20 0 8 3 3 14 4 2* 2 4 1 4 9 0 1 5 0 15 8 1 6 10 0 10 5 1* 9 13 0 Which items are siblings of item 10?

What are the values of the four pointers associates with item 3 (identify each of the pointers)?

How many children did item 3 have when it first became a child of item 7?

How many children did item 10 have when it first became a child of item 8?

Suppose the item 2 is deleted from the heap. Modify the printout to show the effect of this.

  1. (15 points) How many changekey operations are performed by Dijkstra’s algorithm when executed on the graph shown below with vertex v 1 as the source vertex?

Generalize this example to obain an n vertex graph on which Dijkstra’s algorithm performs Ω( n^2 ) changekey operations. Draw a diagram of this graph and explain why Dijkstra’s algorithm does require Ω( n^2 ) changekey operations.

v 1 1 v 2 v 3 v 4 v 5

6

(^111)

6

6

4

2

4

v 1 1 v 2 v 3 v 4 v 5

6

(^111)

6

6

4

2

4

  1. (15 points) Let G be a directed graph and t be a designated destination vertex. Let T be a reverse shortest path tree with destination t. That is, T is a spanning tree of G directed toward t in which all paths are shortest paths. Define p ( u ) be the first vertex (after u ) on the tree path from u to t. Let secondBest ( u ) be the first vertex (after u ) on a second-best path from u to t. More precisely, if v is secondBest ( u ), then vp ( u ), ( u , v ) is an edge and there is no other such vertex wp ( u ), for which the shortest path from u to t that starts with w is shorter than the shortest path from u to t that starts with v. Fill in the body of the C++ program shown below to compute secondBest ( u ) for all vertices ut. Your program should run in O ( m ) time, where m is the number or edges in G. void secondBest(wdigraph G, vertex p[], int d[], vertex sb[]) { // Return the second best next hop vertex of u in sb[u] for // all vertices u. p[u] is the parent of u in the shortest // path tree and d[u] is the length of the shortest path // from u to the destination. vertex u, v; edge e;
  1. (10 points). The figure below represents an instance of the minimum cost, maximum flow problem. What is the cost of the flow that is shown?

Apply two steps of the minimum cost augmenting path algorithm. Show the changes resulting from the first step by modifying the first figure. Show these changes and the changes resulting from the second step by modifying the second figure.

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

cap,flow,cost

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

cap,flow,cost

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

3,__,

5,__,

2,__,

6,,4 3,,

4,__,

3,__,

1,__,

2,__,

2,__,

1,__,

4,__,

s

c f

t

h g

b

a

d

e

  1. (15 points) The figure below shows an intermediate state in the computation of the Edmonds-Karp algorithm for finding a maximum size matching in a general graph., with

blossoms indicated by the shaded areas.

Draw a picture of the partition data structure associated with this state of the computation (there is no single right answer here, but your answer should be consistent with the figure).

For each blossom, identify its bridge , by marking it with the letter B.

What is the augmenting path found if edge { g , l } is examined next?

List the edges in the matching, after the corresponding augmentation is performed.

j c

d g i

k

b e h

f

l m n

−^ +

q

p

r

j c

d g i

k

b e h

f

l m n

−^ +

q

p

r