Docsity

CSE 421 Final Exam, Exams of Algorithms and Programming

Toggle sidebar
bg1
University of Washington December 12, 2005
Department of Computer Science and Engineering
CSE 421, Fall 2005
Final Exam, December 12, 2005
NAME:
Instructions:
•Closed book, closed notes, no calculators
•Time limit: 1 hour 50 minutes
•Answer the problems on the exam paper.
•If you need extra space use the back of a page
•Problems are not of equal difficulty, if you get stuck on
a problem, move on.
1 /15
2 /10
3 /15
4 /20
5 /25
6 /10
7 /15
8 /15
9/15
10 /15
Total /155
pf3
pf4
pf5
pf8

Partial preview of the text

Download CSE 421 Final Exam and more Exams Algorithms and Programming in PDF only on Docsity!

University of Washington December 12, 2005 Department of Computer Science and Engineering CSE 421, Fall 2005

Final Exam, December 12, 2005

NAME:

Instructions:

  • Closed book, closed notes, no calculators
  • Time limit: 1 hour 50 minutes
  • Answer the problems on the exam paper.
  • If you need extra space use the back of a page
  • Problems are not of equal difficulty, if you get stuck on a problem, move on.

Total /

Give solutions to the following recurrences. Justify your answers.

a) T (n) =

{ T (n − 1) + n if n > 0 1 if n = 0

b) T (n) =

{ 17 T (n/17) + n if n > 1 0 if n = 0

c)

T (n) =

{ 3 T (n/4) + n if n > 1 0 if n = 0

Consider the following flow graph G, with an assigned flow f. The pair x/y indicates that the edge is carrying a flow x and has capacity y.



@ @ @ @ @ @

@R



5 / 10

6

2 / 4



2 / 9

6

0 / 4



0 / 6



4 / 9

?

?

6

0 / 12



2 / 10

6

1 / 8

@ @ @ @ @ @

@R

s (^) t

a) Draw the residual graph Gf for the flow f.

s (^) t

b) Give as tight an upperbound on the number of iterations remaining as you can, assuming that the Ford-Fulkerson algorithm is being used to compute a maximum flow. Justify your answer.

What is the fastest known algorithm for each of the following problems? Give a short description or citation (no more than two sentences each). What is the run time of the fastest algorithm? (You may interpret “fastest algorithm” as “fastest algorithm discussed in class”. There are theoretical results on some of these problems that were beyond the scope of the course.”

  1. Given a directed graph G and vertices s, and t, determine the smallest number of edges to remove to separate the graph into two pieces, one containing s, the other t.
  2. Solving the single source shortest paths problem on a directed graph with n vertices and m edges.
  3. Multiplying two n-bit numbers.
  4. Determining if a directed graph has a negative cost cycle.
  5. Finding a simple cycle containing all of the vertices of a directed graph.

Let B = b 1 ,... , bn be a binary sequence. Give a polynomial time algorithm that finds the longest alternating subsequence 0, 1 , 0 , 1 , 0 , 1 ,... of B. A subsequence does not require the digits to be consecutive. The subsequence should start with 0.

Problem 9 (15 points):

You have been placed in charge of hiring at Moogle. You have job classifications J 1 ,... , Jm, and it has been determined that for k = 1,... , m, dk new employees need to be hired for job Jk. The HR department has idenitified candidates C 1 ,... , Cn the company is willing to hire, and for each candidate Ci has a list li 1 ,... , liji of jobs that the candidate could fill. Since you were hired by Moogle primarily because of your prowess in algorithms, you realize this is the perfect opportunity to demonstrate your worth to the company. Show how you can use network flow to determine if the pool of candidates can fill the available jobs, and if so, assign each candidate to a job they are qualified for. (Don’t forget to show how you would actually compute the assignment of people to jobs.)

Give an algorithm to compute the longest common subsequence of three sequences. Given sequences A = a 1 ,... , an, B = b 1 ,... , bn, and C = c 1 ,... , cn the algorithm should find a sequence D = d 1 ,... , dk of maximum length that is a subsequence of A, B, and C. For this problem, it is only necessary to have your algorithm compute the length of the Longest Common Subseqence. Give a short justification of why your algorithm works.