Data Structures - Efficient Algorithms and Intractable Problems - Exams, Exams of Algorithms and Programming

Main points of this exam paper are: Data Structures, Information Requested, Statements Initialize, Structure Descibed, Data Structures, Resulting Data, Structure, Including Rank, Prim'S Algorithm, Implementation

Typology: Exams

2012/2013

Uploaded on 04/02/2013

sushmi_98
sushmi_98 🇮🇳

4.5

(4)

51 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 170, Spring 2000
Midterm #1
Professor M. Clancy
This is an open-book test. You have approximately eighty minutes to complete it. You may consult any
books, notes or other paper-based inanimate objects available to you. To avoid confusion, read the problems
carefully. If you find it hard to understand a problem, ask us to explain it. If you have a question during the
test, please come to the front or the side of the room to ask it.
This exam comprises 15% of the points on which your final grade will be based. Partial credit may be given
for wrong answers. Your exam should contain six problems (numbered 0 through 5) on eight pages, with two
more blank pages at the back of the exam. Please write your answers in the spaces provided in the test; in
particular, we will not grade anything on the back of an exam page unless we are clearly told on the front of
the page to look there.
Relax -- this exam is not worth having a heart failure about.
Problem #0 - 1 point, 1 minute
Put your name on each page. Also make sure you have provided the information requested on the first page.
Problem #1 - 4 points, 10 minutes
Suppose that the following statements initialize the union/find structure descibed in CLR section 22.3.
for (k=0; k
On the next page show the data structures, including ranks of representative elements, that result for each of the following statements. Assume that the statements are executed in sequence. Also assume, as in CLR, that the path compression and union-by-rank optimizations are used, and that the representative element of the second argument becomes the parent when the two arguments have equal rank.
Union (0,1);
Union (2,3);
Union (0,2);
Union (4,5);
Union (0,4);
Results of Union calls
|
call | resulting data structure, including rank(s)
------------+-----------------------------------------------------------
Union(0,1); |
|
CS 170, Midterm #1, Spring 2000
CS 170, Spring 2000 Midterm #1 Professor M. Clancy 1
pf3
pf4
pf5

Partial preview of the text

Download Data Structures - Efficient Algorithms and Intractable Problems - Exams and more Exams Algorithms and Programming in PDF only on Docsity!

CS 170, Spring 2000

Midterm

Professor M. Clancy

This is an open-book test. You have approximately eighty minutes to complete it. You may consult any books, notes or other paper-based inanimate objects available to you. To avoid confusion, read the problems carefully. If you find it hard to understand a problem, ask us to explain it. If you have a question during the test, please come to the front or the side of the room to ask it.

This exam comprises 15% of the points on which your final grade will be based. Partial credit may be given for wrong answers. Your exam should contain six problems (numbered 0 through 5) on eight pages, with two more blank pages at the back of the exam. Please write your answers in the spaces provided in the test; in particular, we will not grade anything on the back of an exam page unless we are clearly told on the front of the page to look there.

Relax -- this exam is not worth having a heart failure about.

Problem #0 - 1 point, 1 minute

Put your name on each page. Also make sure you have provided the information requested on the first page.

Problem #1 - 4 points, 10 minutes

Suppose that the following statements initialize the union/find structure descibed in CLR section 22.3.

for (k=0; k

On the next page show the data structures, including ranks of representative el

Union (0,1); Union (2,3); Union (0,2); Union (4,5); Union (0,4);

Results of Union calls

call | resulting data structure, including rank(s) ------------+----------------------------------------------------------- Union(0,1); | |

CS 170, Spring 2000 Midterm #1 Professor M. Clancy 1

Union(2,3); | | | | | | | |

Union(0,2); | | | | | | | | | | |

Union(4,5); | | | | | | ------------+----------------------------------------------------------- Union(0,4); | | | | | | | | | | | | | | |

Problem #1 - 4 points, 10 minutes 2

Problem #3 - 3 points, 10 minutes

Give a tight estimate for the following recurrene, simplified as much as possible. Assume that values of T for small values of n are constant; that is, T(0) = ((1), T(1)=((1), T(2)=((1).

T(n) = 9T(n/3) + n^2 + n lg n

Explain your answer.

Problem #4 - 8 points, 20 minutes

Prove that a graph G = (V,E) with no isloated vertices is strongly connected if and only if there is a circuit in G that inclued every edge at least once (and possibly more than once).

Problem #5 - 8 points, 24 minutes

Give an efficient algorithm that, given a directed acyclic graph G = (V,E) and a vertex a in V, counts the number of paths from a to all other vertices. For example, there are five paths from a to b in the graph displayed below, namely aeb, aedb, aceb, acedb, and acdb.

Part B 4

Provide sufficient comments for us to understand how your algorithm works. An incorrect algorithm may earn you partial credit if we can understand it; if you know it won't work, provide a counterexample with your algorithm description.

Posted by HKN (Electrical Engineering and Computer Science Honor Society)

University of California at Berkeley

If you have any questions about these online exams

please contact [email protected].

Problem #5 - 8 points, 24 minutes 5