CSE 421 Introduction to Algorithms Final Exam Winter 2005

Similar documents
CMPSCI 311: Introduction to Algorithms Second Midterm Exam

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

Midterm Exam 2 Solutions

Weighted Activity Selection

CSI 4105 MIDTERM SOLUTION

Lecture 2: Divide and conquer and Dynamic programming

COMPSCI 611 Advanced Algorithms Second Midterm Exam Fall 2017

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

Design and Analysis of Algorithms April 16, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 2

COMPSCI 611 Advanced Algorithms Second Midterm Exam Fall 2017

CS 170 Algorithms Spring 2009 David Wagner Final

Algorithms Exam TIN093 /DIT602

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2013

Dynamic Programming: Interval Scheduling and Knapsack

Design and Analysis of Algorithms

Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009

Algorithm Design and Analysis

Algorithms Re-Exam TIN093/DIT600

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

Maximum flow problem CE 377K. February 26, 2015

directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

IS 709/809: Computational Methods in IS Research Fall Exam Review

Dynamic Programming( Weighted Interval Scheduling)

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

Greedy Algorithms My T. UF

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov

This means that we can assume each list ) is

Algorithms and Theory of Computation. Lecture 11: Network Flow

CS 170, Fall 1997 Second Midterm Professor Papadimitriou

Lecture 2: Network Flows 1

Algorithms: Lecture 12. Chalmers University of Technology

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Machine Learning, Fall 2009: Midterm

Lecture 18: More NP-Complete Problems

Design and Analysis of Algorithms March 12, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 1

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2006

Algorithm Design CS 515 Fall 2015 Sample Final Exam Solutions

Design and Analysis of Algorithms

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Topics in Approximation Algorithms Solution for Homework 3

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2007

CSE 421 NP-Completeness

CS 170 Algorithms Fall 2014 David Wagner MT2

CMPSCI 611: Advanced Algorithms

CMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017

6.046 Recitation 11 Handout

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

Name: Student ID: Instructions:

CSE548, AMS542: Analysis of Algorithms, Fall 2016 Date: Nov 30. Final In-Class Exam. ( 7:05 PM 8:20 PM : 75 Minutes )

Name (NetID): (1 Point)

CSE 421 Dynamic Programming

University of Ottawa

Lexicographic Flow. Dexter Kozen Department of Computer Science Cornell University Ithaca, New York , USA. June 25, 2009

Dynamic Programming. Reading: CLRS Chapter 15 & Section CSE 2331 Algorithms Steve Lai

Exam EDAF August Thore Husfeldt

6. DYNAMIC PROGRAMMING I

Last/Family Name First/Given Name Seat # Exam # Failure to follow the instructions below will constitute a breach of the Honor Code:

Algorithm Design and Analysis

4. How to prove a problem is NPC

Review Questions, Final Exam

CS 580: Algorithm Design and Analysis

Introduction to Algorithms

CMPSCI 611 Advanced Algorithms Midterm Exam Fall 2015

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

COMP Analysis of Algorithms & Data Structures

Math 115 Practice for Exam 2

Dynamic Programming. Cormen et. al. IV 15

MATH 1553, SPRING 2018 SAMPLE MIDTERM 1: THROUGH SECTION 1.5

CSE 202 Dynamic Programming II

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

MATH 1553 PRACTICE MIDTERM 1 (VERSION A)

7.5 Bipartite Matching

Design and Analysis of Algorithms

1 T 1 = where 1 is the all-ones vector. For the upper bound, let v 1 be the eigenvector corresponding. u:(u,v) E v 1(u)

Data Structures and Algorithms (CSCI 340)

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Linear Algebra Exam 1 Spring 2007

NAME (1 pt): SID (1 pt): TA (1 pt): Name of Neighbor to your left (1 pt): Name of Neighbor to your right (1 pt):

ACO Comprehensive Exam March 17 and 18, Computability, Complexity and Algorithms

MATH 1553, C.J. JANKOWSKI MIDTERM 1

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Last/Family Name First/Given Name Seat # Exam # Failure to follow the instructions below will constitute a breach of the Honor Code:

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

CSE 421 Greedy Algorithms / Interval Scheduling

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Copyright 2000, Kevin Wayne 1

CS 350 Algorithms and Complexity

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

NAME: Be clear and concise. You may use the number of points assigned toeach problem as a rough

More on NP and Reductions

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3

Show that the following problems are NP-complete

UNIVERSITY of OSLO. Faculty of Mathematics and Natural Sciences. INF 4130/9135: Algorithms: Design and efficiency Date of exam: 12th December 2014

CPSC 320 Sample Final Examination December 2013

Transcription:

NAME: CSE 421 Introduction to Algorithms Final Exam Winter 2005 P. Beame 14 March 2005 DIRECTIONS: Answer the problems on the exam paper. Open book. Open notes. If you need extra space use the back of a page You have 1 hour and 50 minutes to complete the exam. Please do not turn the page until you are instructed to do so. Good Luck! 1 /33 2 /20 3 /18 4 /20 5 /20 6 /20 7 /20 8 /10 Total /161 1

1. (33 points, 3 each) For each of the following problems circle True or False. You do not need to justify your answer. (a) If f and g are two different flows on the same flow graph (G, s, t) and if ν(f) ν(g) then every edge e in G has f(e) g(e). True False (b) If f is a maximum flow on a flow graph (G = (V, E), s, t) and B is the set of vertices in V that can reach t in the residual graph G f then (V B, B) is a minimum capacity s-t cut in G. True False (c) If f is a maximum flow on a flow graph (G, s, t) and (S, T ) is a minimum capacity s-t cut in G then every edge e having endpoints on different sides of (S, T ) has f(e) equal to the capacity of e. True False (d) If problem B is NP -hard and A P B then A is NP -hard. True False (e) If problem A is NP -hard and A P B then B is NP -hard. True False (f) If P NP then every problem in NP requires exponential time. True False (g) If problem A is in P then A P B for every problem B in NP. True False (h) If G is a weighted graph with n vertices and m edges that does not contain negativeweight cycle, then the iteration of the Bellman-Ford algorithm will reach a fixed point in at most n 1 rounds. True False (i) If G is a weighted graph with n vertices and m edges that does contain negative-weight cycle, then for every vertex v in G the shortest path from v to t in G containing n edges is strictly shorter than the shortest path from v to t in G containing n 1 edges. True False (j) A divide and conquer algorithm for n n matrix multiplication that solves the problem using 24 matrix multiplication subproblems of size n/3 and O(n 2 ) additional work for recombining would be more efficient than the usual Θ(n 3 ) matrix multiplication algorithm. True False (k) A divide and conquer algorithm for the selection problem that reduced the problem on lists of size n to one selection problem of size 3n/20 and another selection problem of size 9n/10 plus a linear amount of extra work would yield a linear time algorithm. True False 2

2. (20 points) Consider the following flow network with a flow f shown. An edge labelled b means that it has capacity b and flow 0. An edge labelled a/b means that the flow on that edge is a and the capacity is b. 4/9 a 7/7 c 5/5 s 3/8 2/5 6 t 8/9 b 7/10 d 7/12 (a) (10 points) Draw the residual graph G f. a c s t b d (b) (3 points) What augmenting path in this graph would result in the greatest increase in flow value? (List the names of the vertices on this path in order.) (c) (7 points) On the diagram below, indicate the new flow values resulting from augmenting along the path you found in part (b). 9 a 7 c 5 5 s 8 6 t 9 b 10 d 12 3

3. (18 points) For each of the following recurrences give the time and space that would be required by a simple dynamic programming algorithm to compute the answer where the values of the w function are given as input. (a) Compute OP T (n) where OP T (1) = 1 and OP T (i) = min 1 j<i {OP T (j)/j + w(j)}. Time O( ) Space O( ) (b) Compute OP T (m, n) where OP T (i, 0) = OP T (0, j) = 0 for all i and j and OP T (i, j) = min{op T (i 1, j) + 2, OP T (i, j 1) + 1, OP T (i 1, j 1)/2 + w(j)} for i, j > 0. Time O( ) Space O( ) (c) Compute OP T (1, n) where OP T (i, i) = 0 for all i, and OP T (i, j) = min{op T (i, k) + OP T (k + 1, j) + w(k) : i k < j} for all i < j. Time O( ) Space O( ) 4

4. (20 points) You are given a sequence of n bits x 1,..., x n {0, 1}. Your output is to be either any i such that x i = 1 or the value 0 if the input is all 0 s. The only operation you are allowed to use to access the inputs is a function Group-Test where { 1 if some bit in xi,..., x j has value 1 Group-Test(i, j) = 0 if all bits in x i,..., x j have value 0 (Historical Note: In World War I, the army was testing recruits for syphilis which was rare but required a time-consuming though accurate blood test. They realized that they could pool the blood from several recruits at once and save time by eliminating large groups of recruits who didn t have syphilis.) (a) (15 points) Design a divide and conquer algorithm to solve the problem that uses only O(log n) calls to Group-Test in the worst case. Your algorithm should never access the x i directly. (b) (5 points) Briefly justify your bound on the number of calls. 5

5. (20 points) In classifying butterflies of several species, a biologist makes time-consuming comparisons between butterfly features to determine whether or not two butterflies are the same species. A biologist wants to determine as efficiently as possible whether or not there is a dominant species among n butterfly specimens, B = (b 1,..., b n ). (A dominant species is one that occurs strictly more than n/2 times in the list of specimens.) (a) Describe a divide and conquer algorithm Dominant(B, n) to tell the biologist how to do this in O(n log n) applications of operation Same(b, b ) which returns true if b and b are the same species and false otherwise. (b) Explain why your solution is correct. (c) Write the recurrence that justifies your claim for the O(n log n) running time. 6

6. (20 points) You are given a directed acyclic graph G = (V, E) and a node node t V. Design a linear time algorithm to compute for each vertex v V the number of different paths from v to t in G. Analyze its running time in terms of n = V and m = E. 7

7. (20 points) The Number Partition problem asks, given a collection of non-negative integers y 1,..., y n whether or not it is possible to partition these numbers into two groups so that the sum in each group is the same. Prove that Number Partition is NP-complete by solving the following problems. (a) Show that Number Partition is in NP. (b) Show that Subset Sum P Number Partition Recall that in the Subset Sum problem we are given a collection of integers (which can be positive and negative), we want to see if it is possible find a subset that sum up to 1. Hint: Given an input to Subset Sum include two large numbers whose size differs by S 2 where S is the sum of all input numbers. 8

8. (10 points) The two processor interval scheduling problem takes as input a sequence of request intervals (s 1, f 1 ),..., (s n, f n ) just like the unweighted interval scheduling problem except that it produces two disjoint subsets A 1, A 2 [n] such that all requests in A 1 are compatible with each other and all requests in A 2 are compatible with each other and A 1 A 2 is as large as possible. (A 1 might contain requests that are incompatible with requests in A 2.) Does the following greedy algorithm produce optimal results? If yes argue why it does; if no produce a counterexample. Sort requests by increasing finish time A 1 = A 2 = while there is any request (s i, f i ) compatible with either A 1 or A 2 do Add the first unused request, if any, compatible with A 1 to A 1. Add the first unused request, if any, compatible with A 2 to A 2. end while 9