This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 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 closedbook 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 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) Prims Algorithm (b) Kruskals 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 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 lefttoright 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...
View
Full
Document
This note was uploaded on 01/15/2012 for the course COT 5405 taught by Professor Ungor during the Fall '08 term at University of Florida.
 Fall '08
 UNGOR
 Algorithms

Click to edit the document details