This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: NAME: CSE 331 Introduction to Algorithm Analysis and Design Sample Final Exam Solutions 1. (5 2 = 10 points ) Answer True or False to the following questions. No justification is required. (Recall that a statement is true only if it is logically true in all cases while it is is false if it is not true in some case). Note: Im providing justifications for the questions below for your understanding. In the actual exam for Q1, you of course only have to say True or false. (a) Depth First Search (DFS) is a linear time algorithm. True . The input graph can be represented as an adjacency list of total size O ( m + n ). We saw in the lecture that DFS runs in time O ( m + n ) and thus, has a linear running time. (b) n is O ( (log n ) log n ) . True . Note that n = 2 log n and (log n ) log n = 2 log log n log n . Now the statement follows as log n log log n log n for large enough n . (c) There is no algorithm that can compute the Minimum Spanning Tree (MST) of a graph on n vertices and m edges in time asymptotically faster than O ( m log n ). False . As I mentioned in the class, there exists algorithms to compute the MST in time O ( m ( m, n )), where ( m, n ) is the inverse Ackerman function and is asymptotically (much) smaller than log n . (This fact was also mentioned with Q2 in HW 8.) (d) Let G be a graph with a negative cycle. Then there is no pair of vertices that has a finite cost shortest path. False . Consider a graph that has an edge ( s, t ) with cost 1 and a disjoint negative cycle. In this graph the shortest s t path has cost 1. (e) Every computational problem on input size n can be solved by an algorithm with running time polynomial in n . False . There are many ways to show this is false, here is one. Consider the problem, where given n numbers as input, the algorithm has to output all the permutations of the n numbers. Since there are n ! permutations that need to be output, every algorithm for this problem runs in exponential time. 2. (5 6 = 30 points ) Answer True or False to the following questions and briefly JUSTIFY each answer. A correct answer with no or totally incorrect justification will get you 2 out of the total 6 points. (Recall that a statement is true only if it is logically true in all cases while it is is false if it is not true in some case). (a) The following algorithm to check if the input number n is a prime number runs in polynomial time. 1 For every integer 2 i n , check if i divides n . If so declare n to be not a prime. If no such i exists, declare n to be a prime....
View
Full
Document
This note was uploaded on 12/11/2011 for the course CSE 331 taught by Professor Rudra during the Fall '11 term at SUNY Buffalo.
 Fall '11
 RUDRA

Click to edit the document details