{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Finalsol - COT 5405 Analysis of Algorithms Spring 2010...

This preview shows pages 1–5. Sign up to view the full content.

COT 5405 Analysis of Algorithms, Spring 2010 Final Comprehensive Exam April 29, 2010 Name: UFID: Instructions: 1. Write neatly and legibly. 2. This is a closed-book exam. No calculator. 3. While grading, not only your final answer but also your approach to the problem will be evaluated 4. You have to attempt four problems; You have to choose EX- ACTLY two problems out of 1, 2 and 3. If you solve all three, only problems 1 and 2 will be graded.Problem 4 and 5 are com- pulsory. 5. Total time for the exam is 120 minutes 6. You are not allowed to use a calculator for this exam I have read carefully, and have understood the above instructions. On my honor, I have neither given nor received unauthorized aid on this examination. Signature: Date: (MM) / (DD) / (YYYY) 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1. [1 page][25points][Choose 2 problems out of 1, 2 and 3] DIVIDE AND CON- QUER The following recursive algorithm sorts a sequence of n numbers. Write down a re- currence describing the running time of the algorithm as a function of n. Solve the recurrence relation and state the final time complexity. def triplesort(seq): if n <= 1: return if n == 2: replace seq by [min(seq),max(seq)] return triplesort(first 2n/3 positions in seq) triplesort(last 2n/3 positions in seq) triplesort(first 2n/3 positions in seq) Solution: T ( n ) = 3 T ( 2 n 3 ) + Θ(1) Note that T ( n ) = Θ( n 2 . 71 ) 2
2. [1 page][25points][Choose 2 problems out of 1, 2 and 3] GREEDY ALGO- RITHM Find the minimum spanning tree for the following graph using: (a) Prim’s Algorithm (b) Kruskal’s Algorithm Illustrate how MST is found each step for both algorithms. 1 2 5 3 4 6 2 3 1 5 4 3 Solution: 1 2 5 3 4 6 2 3 1 5 4 3 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3. [1 page][25points][Choose 2 problems out of 1, 2 and 3] DYNAMIC PRO- GRAMMING Given bit strings X = x 1 . . . x m , Y = y 1 . . . y n and Z = z 1 . . . z m + n , if Z can be obtained by interleaving the bits in X and Y in a way that maintains the left-to-right order of the bits in X and Y, then we say Z is an interleaving of X and Y. For example if X = 101 and Y = 01 then x 1 x 2 y 1 x 3 y 2 = 10011 is an interleaving of X and Y , whereas 11010 is not. Give the most efficient algorithm you can to determine if Z is an interleaving of
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern