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

Size: px
Start display at page:

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

Transcription

1 NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours INSTRUCTIONS TO STUDENTS 1. This assessment consists of Eight (8) questions and comprises 18 printed pages (including this page). 2. Answer ALL questions. 3. Maximum marks for the paper is This is an Open Book assessment. 5. Write your student number on each page. 6. Student Number (DO NOT WRITE YOUR NAME) Question Internal Examiner External Examiner Average Q1a Q1b Q2 Q3 Q4 Q5 Q6 Q7 Q8 Total

2 CS4232 Question 1 For each of the following parts, state whether the statement is true or false, and give a short proof for correctness of your answer. (a) (4 marks) Suppose T (0) = T (1) = 1. For n > 1, suppose T (n) = 3T ( n/2 ) + 5n Then, T (n) Θ(n 2 log n) Answer: False. Using master theorem, a = 3, b = 2, k = 2. Thus, b k = 2 2 > 3 = a. Thus, T (n) Θ(n 2 ), and thus not Θ(n 2 log n). 2

3 (b) (4 marks) n! 2 n O(n2 ) Answer: False. Suppose by way of contradiction otherwise that n! 2 n cn 2, for n n 0 and some constant c > 0. But, n! 2 n(n 1)(n 2) n 16 n 3 2 n , for n 100. Thus, n 3 64 cn2, for n n 0, or n 64c, for n n 0, which is a contradiction. 3

4 Question 2 (6 marks) Suppose we are given n sorted lists. Suppose the only further operations allowed to us is to merge two sorted lists (which may be among the above lists or obtained in turn by merging some of the lists), as done in class. Suppose further that merging two lists of size k and l requires time k + l. Give an algorithm to determine the order in which the n lists (having m 1, m 2,..., m n numbers respectively), should be merged so that the merging operations take the least amount of time. Note that the aim above is to minimize the merging time of lists (and not the time taken by your algorithm). Give an argument why your algorithm gives optimal order of merging. Ans: This problem is similar to the algorithm for optimal Huffman coding. Just as in optimal Huffman coding, we merge the two lists with least weights first, to form a combined list (which is then again put back in the pool of lists). We continue in a manner similar to optimal Huffman coding. Just as optimal Huffman coding gives optimal coding, the above method will give the least total cost for merging the lists. 4

5 Question 3 (6 marks) Build a table to show how the dynamic programming algorithm done in class will work for finding the optimal algorithm for the following matrix multiplication. M 1 M 2 M 3 M 4, where M 1 is a matrix of size 8 3 M 2 is a matrix of size 3 2 M 3 is a matrix of size 2 5 M 4 is a matrix of size 5 7 Answer: F (1, 1) = F (2, 2) = F (3, 3) = 0. F (1, 2) = = 48 F (2, 3) = = 30 F (3, 4) = = 70 F (1, 3) = min(f (1, 2)+F (3, 3)+8 2 5, F (1, 1)+F (2, 3)+8 3 5) = min( , ) = 128 F (2, 4) = min(f (2, 3)+F (4, 4)+3 5 7, F (2, 2)+F (3, 4)+3 2 7) = min( , ) = 112 F (1, 4) = min(f (1, 1) + F (2, 4) , F (1, 2) + F (3, 4) , F (1, 3) + F (4, 4) ) = min( , , ) = min(280, 230, 408) =

6 Question 4 (6 marks) Recall the problem of providing coin change: We are given coin denominations d 1 > d 2 > d 3 >... > d n = 1 and an amount S. The aim is to find the minimal number of coins needed to provide change for amount S using the denominations d 1, d 2,... d n. Prove or give a counterexample to the following claim: Claim: For any given coin denominations d 1, d 2,..., d n : if the greedy algorithm done in class is optimal for obtaining coin change for all amounts S n LCM(d 1, d 2,..., d n ), then the greedy algorithm is optimal for all values of S. Here LCM( ) denotes the least common multiple of the arguments. Answer: Suppose the greedy algorithm is optimal for any S n LCM(d 1, d 2,..., d n ). Now suppose by induction we have shown that the greedy algorithm is optimal for all values of S m. We then show that it is optimal for S = m + 1. Consider the optimal solution for S = m + 1. As m + 1 > n LCM(d 1, d 2,..., d n ), there must exist an i with 1 i n, such that more than LCM(d 1, d 2,..., d n ) value was obtained by using coins of denomination d i. Thus, we can replace the LCM(d 1, d 2,..., d n ) value formed using these coins by using coins of denomination d 1 without increasing the number of coins used. Thus, there is at least one coin of denomination d 1 used by optimal solution. Removing this coin from both greedy and optimal solution and using induction, we have that greedy method is optimal. 6

7 Question 5 (6 marks) Consider the following weighted adjacency matrix wt for an undirected graph having vertices {1, 2, 3, 4, 5}. In the adjacency matrix below, the entry wt(i, j) denotes the weight of the edge between vertex i and j (where the weight is if there is no such edge). wt = Find the shortest path distance starting from vertex 1 to all other vertices using Dijkstra s algorithm done in class. Please show how the distance vector Dist[ ] gets updated after every iteration of the while loop in the algorithm. For this question, you need to give the shortest path distance, and need not give the shortest path itself. Answer: Selected Dist(1) Dist(2) Dist(3) Dist(4) Dist(5) Thus, the optimal distances to vertices 2, 3, 4, 5 are respectively 7, 3, 1 and 4. 7

8 Question 6 (6 marks) Consider the following divide and conquer algorithm for finding a minimal spanning tree proposed by Professor Martin. (a) In case the tree has only one vertex, then return spanning tree as containing the only vertex. (b) Otherwise, divide the set of vertices into two nearly equal halves. (The division in two halves might be arbitrary; in case of odd number of vertices, one half will have one more vertex than the other). (c) Find the minimal spanning tree for each half. (d) Find the minimal weight edge which has two endpoints in two different halves as found in (b) above. (e) Use the edge found in (d) above to connect the two spanning trees found in (c) above. Does the above algorithm always give a minimal spanning tree? If so, give an argument for it. If not, give a counterexample. Ans: No. Consider the following counterexample: G = (V, E), where V = {1, 2, 3, 4} and wt(1, 2) = 9, wt(3, 4) = 1, wt(1, 3) = 1, wt(2, 4) = 2. And, the initial division is {1, 2} and {3, 4}. Then optimal MST is by using the edges (1, 3), (2, 4), (3, 4) (with weight 4). However, the algorithm above will give the spanning tree, (1, 2), (3, 4), (1, 3) (with weight 11). 8

9 Question 7 (6 marks) Suppose T is a Huffman coding tree for the frequencies f 1, f 2, f 3,..., f n, where f 1 and f 2 have the same parent. Consider the tree T with f 1 and f 2 deleted, and the parent of f 1 and f 2 labeled with frequency f 1 + f 2. Consider the following conjecture: If T is optimal for frequencies f 1 +f 2, f 3,..., f n then T is optimal for f 1, f 2,..., f n. Either prove the conjecture to be true or give a counterexample. Ans: conjecture is false, as given by the frequencies, f 1 = 5, f 2 = 6, f 3 = 1. 9

10 Question 8 (6 marks) Consider the following problem. INSTANCE/INPUT: (a) A set U and (b) a collection C of some subsets of U (in other words, C is a subset of power set of U). QUESTION: Does there exist a subset S of U such that for all sets X C, [X S and X (U S) ]. Show that the above problem is NP-complete. Answer: It is easy to see that the above problem is in NP: Guess S and verify that for all sets X C, both X S and X (U S) are nonempty. Consider NAESAT problem V = {x 1, x 2,..., x n }, Cl = {c 1, c 2,..., c m }, and c i = (l 1 i, l2 i, l3 i ). Then reduce NAESAT to the problem of Q4 as follows: U = {u i, w i : 1 i n}. C = {{u i, w i } : 1 i n} {{a 1 i, a2 i, a3 i } : 1 i n}, where ar i = u j, if l r i = x j, and a r i = w j, if l r i = x j. It is straightforward to verify that above reducton can be done in polynomial ti me. Furthermore, if the NAESAT problems has a solution, then S = {u i : x i is true} {w i : x i is false} witnesses the solution for Q4 problem. If the problem in the question has a solution, then note that exactly one of u i, w i belongs to S. Setting x i to be true iff u i S gives a solution to NAESAT problem. 10

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees , 2009 Lecture 5: Shortest Paths & Spanning Trees University of Twente m.uetz@utwente.nl wwwhome.math.utwente.nl/~uetzm/dw/ Shortest Path Problem "#$%&'%()*%"()$#+,&- Given directed "#$%&'()*+,%+('-*.#/'01234564'.*,'7+"-%/8',&'5"4'84%#3

More information

1 Some loose ends from last time

1 Some loose ends from last time Cornell University, Fall 2010 CS 6820: Algorithms Lecture notes: Kruskal s and Borůvka s MST algorithms September 20, 2010 1 Some loose ends from last time 1.1 A lemma concerning greedy algorithms and

More information

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

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016 University of Toronto Department of Electrical and Computer Engineering Final Examination ECE 345 Algorithms and Data Structures Fall 2016 Print your first name, last name, UTORid, and student number neatly

More information

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic).

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic). Trees A tree is a graph which is (a) Connected and (b) has no cycles (acyclic). 1 Lemma 1 Let the components of G be C 1, C 2,..., C r, Suppose e = (u, v) / E, u C i, v C j. (a) i = j ω(g + e) = ω(g).

More information

Breadth-First Search of Graphs

Breadth-First Search of Graphs Breadth-First Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of Breadth-First Search of Graphs a) Single Source

More information

CSE 421 Introduction to Algorithms Final Exam Winter 2005

CSE 421 Introduction to Algorithms Final Exam Winter 2005 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

More information

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) The final exam will be on Thursday, May 12, from 8:00 10:00 am, at our regular class location (CSI 2117). It will be closed-book and closed-notes, except

More information

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

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD Greedy s Greedy s Shortest path Claim 2: Let S be a subset of vertices containing s such that we know the shortest path length l(s, u) from s to any vertex in u S. Let e = (u, v) be an edge such that 1

More information

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9 1 Computational Complexity and Intractability: An Introduction to the Theory of NP Chapter 9 2 Objectives Classify problems as tractable or intractable Define decision problems Define the class P Define

More information

Algorithms Exam TIN093 /DIT602

Algorithms Exam TIN093 /DIT602 Algorithms Exam TIN093 /DIT602 Course: Algorithms Course code: TIN 093, TIN 092 (CTH), DIT 602 (GU) Date, time: 21st October 2017, 14:00 18:00 Building: SBM Responsible teacher: Peter Damaschke, Tel. 5405

More information

CS325: Analysis of Algorithms, Fall Final Exam

CS325: Analysis of Algorithms, Fall Final Exam CS: Analysis of Algorithms, Fall 0 Final Exam I don t know policy: you may write I don t know and nothing else to answer a question and receive percent of the total points for that problem whereas a completely

More information

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note

More information

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty.

NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty. EXAM 2 solutions (COT3100, Sitharam, Spring 2017) NAME:last first: UF-ID Section NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty. (1) Are the following functions one-to-one

More information

CS781 Lecture 3 January 27, 2011

CS781 Lecture 3 January 27, 2011 CS781 Lecture 3 January 7, 011 Greedy Algorithms Topics: Interval Scheduling and Partitioning Dijkstra s Shortest Path Algorithm Minimum Spanning Trees Single-Link k-clustering Interval Scheduling Interval

More information

Exam Practice Problems

Exam Practice Problems Math 231 Exam Practice Problems WARNING: This is not a sample test. Problems on the exams may or may not be similar to these problems. These problems are just intended to focus your study of the topics.

More information

Algorithms and Data Structures (COMP 251) Midterm Solutions

Algorithms and Data Structures (COMP 251) Midterm Solutions Algorithms and Data Structures COMP 251) Midterm Solutions March 11, 2012 1. Stable Matching Problem a) Describe the input for the stable matching problem. Input: n men and n women. For each man, there

More information

(1) Which of the following are propositions? If it is a proposition, determine its truth value: A propositional function, but not a proposition.

(1) Which of the following are propositions? If it is a proposition, determine its truth value: A propositional function, but not a proposition. Math 231 Exam Practice Problem Solutions WARNING: This is not a sample test. Problems on the exams may or may not be similar to these problems. These problems are just intended to focus your study of the

More information

CS 170 Algorithms Spring 2009 David Wagner Final

CS 170 Algorithms Spring 2009 David Wagner Final CS 170 Algorithms Spring 2009 David Wagner Final PRINT your name:, (last) SIGN your name: (first) PRINT your Unix account login: Your TA s name: Name of the person sitting to your left: Name of the person

More information

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

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3 Banner ID: Name: Midterm Exam CS 3110: Design and Analysis of Algorithms June 20, 2006 Group 1 Group 2 Group 3 Question 1.1 Question 2.1 Question 3.1 Question 1.2 Question 2.2 Question 3.2 Question 3.3

More information

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

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions PRINT Your Name: Answer: Oski Bear SIGN Your Name: PRINT Your Student ID: CIRCLE your exam room: Dwinelle

More information

Advanced Combinatorial Optimization September 22, Lecture 4

Advanced Combinatorial Optimization September 22, Lecture 4 8.48 Advanced Combinatorial Optimization September 22, 2009 Lecturer: Michel X. Goemans Lecture 4 Scribe: Yufei Zhao In this lecture, we discuss some results on edge coloring and also introduce the notion

More information

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

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2007 University of New Mexico Department of Computer Science Final Examination CS 362 Data Structures and Algorithms Spring, 2007 Name: Email: Print your name and email, neatly in the space provided above;

More information

Combinatorial Optimization

Combinatorial Optimization Combinatorial Optimization Problem set 8: solutions 1. Fix constants a R and b > 1. For n N, let f(n) = n a and g(n) = b n. Prove that f(n) = o ( g(n) ). Solution. First we observe that g(n) 0 for all

More information

Advanced Combinatorial Optimization September 24, Lecture 5

Advanced Combinatorial Optimization September 24, Lecture 5 18.438 Advanced Combinatorial Optimization September 24, 2009 Lecturer: Michel X. Goemans Lecture 5 Scribe: Yehua Wei In this lecture, we establish the connection between nowhere-zero (nwz) k-flow and

More information

Propositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications

Propositional Logic. What is discrete math? Tautology, equivalence, and inference. Applications What is discrete math? Propositional Logic The real numbers are continuous in the senses that: between any two real numbers there is a real number The integers do not share this property. In this sense

More information

Lecture 2: Divide and conquer and Dynamic programming

Lecture 2: Divide and conquer and Dynamic programming Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in

More information

Analysis of Algorithms

Analysis of Algorithms September 29, 2017 Analysis of Algorithms CS 141, Fall 2017 1 Analysis of Algorithms: Issues Correctness/Optimality Running time ( time complexity ) Memory requirements ( space complexity ) Power I/O utilization

More information

CMPSCI 311: Introduction to Algorithms Second Midterm Exam

CMPSCI 311: Introduction to Algorithms Second Midterm Exam CMPSCI 311: Introduction to Algorithms Second Midterm Exam April 11, 2018. Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more

More information

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids

More information

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

ACO Comprehensive Exam March 17 and 18, Computability, Complexity and Algorithms 1. Computability, Complexity and Algorithms (a) Let G(V, E) be an undirected unweighted graph. Let C V be a vertex cover of G. Argue that V \ C is an independent set of G. (b) Minimum cardinality vertex

More information

Exam in Discrete Mathematics

Exam in Discrete Mathematics Exam in Discrete Mathematics First Year at The TEK-NAT Faculty June 10th, 2016, 9.00-13.00 This exam consists of 11 numbered pages with 16 problems. All the problems are multiple choice problems. The answers

More information

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

IS 709/809: Computational Methods in IS Research Fall Exam Review IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm

More information

CSI 4105 MIDTERM SOLUTION

CSI 4105 MIDTERM SOLUTION University of Ottawa CSI 4105 MIDTERM SOLUTION Instructor: Lucia Moura Feb 6, 2010 10:00 am Duration: 1:50 hs Closed book Last name: First name: Student number: There are 4 questions and 100 marks total.

More information

CS60007 Algorithm Design and Analysis 2018 Assignment 1

CS60007 Algorithm Design and Analysis 2018 Assignment 1 CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in

More information

Algorithms Design & Analysis. Approximation Algorithm

Algorithms Design & Analysis. Approximation Algorithm Algorithms Design & Analysis Approximation Algorithm Recap External memory model Merge sort Distribution sort 2 Today s Topics Hard problem Approximation algorithms Metric traveling salesman problem A

More information

Algorithm Design Strategies V

Algorithm Design Strategies V Algorithm Design Strategies V Joaquim Madeira Version 0.0 October 2016 U. Aveiro, October 2016 1 Overview The 0-1 Knapsack Problem Revisited The Fractional Knapsack Problem Greedy Algorithms Example Coin

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees 695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci

More information

CMPSCI 611 Advanced Algorithms Midterm Exam Fall 2015

CMPSCI 611 Advanced Algorithms Midterm Exam Fall 2015 NAME: CMPSCI 611 Advanced Algorithms Midterm Exam Fall 015 A. McGregor 1 October 015 DIRECTIONS: Do not turn over the page until you are told to do so. This is a closed book exam. No communicating with

More information

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-Completeness. Until now we have been designing algorithms for specific problems NP-Completeness 1 Introduction Until now we have been designing algorithms for specific problems We have seen running times O(log n), O(n), O(n log n), O(n 2 ), O(n 3 )... We have also discussed lower

More information

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity CS 350 Algorithms and Complexity Winter 2019 Lecture 15: Limitations of Algorithmic Power Introduction to complexity theory Andrew P. Black Department of Computer Science Portland State University Lower

More information

CS 350 Algorithms and Complexity

CS 350 Algorithms and Complexity 1 CS 350 Algorithms and Complexity Fall 2015 Lecture 15: Limitations of Algorithmic Power Introduction to complexity theory Andrew P. Black Department of Computer Science Portland State University Lower

More information

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Contents Lecture 4 Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Jonas Skeppstedt (jonasskeppstedt.net) Lecture 4 2018

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Shortest paths Minimum Spanning Tree Sofya Raskhodnikova 9/14/016 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,

More information

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

CPSC 320 (Intermediate Algorithm Design and Analysis). Summer Instructor: Dr. Lior Malka Final Examination, July 24th, 2009 CPSC 320 (Intermediate Algorithm Design and Analysis). Summer 2009. Instructor: Dr. Lior Malka Final Examination, July 24th, 2009 Student ID: INSTRUCTIONS: There are 6 questions printed on pages 1 7. Exam

More information

CMSC Discrete Mathematics SOLUTIONS TO FIRST MIDTERM EXAM October 18, 2005 posted Nov 2, 2005

CMSC Discrete Mathematics SOLUTIONS TO FIRST MIDTERM EXAM October 18, 2005 posted Nov 2, 2005 CMSC-37110 Discrete Mathematics SOLUTIONS TO FIRST MIDTERM EXAM October 18, 2005 posted Nov 2, 2005 Instructor: László Babai Ryerson 164 e-mail: laci@cs This exam contributes 20% to your course grade.

More information

7.4 DO (uniqueness of minimum-cost spanning tree) Prove: if all edge weights are distinct then the minimum-cost spanning tree is unique.

7.4 DO (uniqueness of minimum-cost spanning tree) Prove: if all edge weights are distinct then the minimum-cost spanning tree is unique. Algorithms CMSC-700 http://alg1.cs.uchicago.edu Homework set #7. Posted -19. Due Wednesday, February, 01 The following problems were updated on -0: 7.1(a), 7.1(b), 7.9(b) Read the homework instructions

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Spring 207 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 8 March 28, 207 Chandra Chekuri (UIUC) CS374 Spring 207 / 56 Part I Shortest Paths

More information

CPSC 320 Sample Final Examination December 2013

CPSC 320 Sample Final Examination December 2013 CPSC 320 Sample Final Examination December 2013 [10] 1. Answer each of the following questions with true or false. Give a short justification for each of your answers. [5] a. 6 n O(5 n ) lim n + This is

More information

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation: Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O

More information

University of California Berkeley CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan. Midterm 2 Solutions

University of California Berkeley CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan. Midterm 2 Solutions University of California Berkeley Handout MS2 CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan Midterm 2 Solutions Problem 1. Provide the following information:

More information

Approximation algorithm for Max Cut with unit weights

Approximation algorithm for Max Cut with unit weights Definition Max Cut Definition: Given an undirected graph G=(V, E), find a partition of V into two subsets A, B so as to maximize the number of edges having one endpoint in A and the other in B. Definition:

More information

CSE 321 Solutions to Practice Problems

CSE 321 Solutions to Practice Problems CSE 321 Solutions to Practice Problems Instructions: Feel free NOT to multiply out binomial coefficients, factorials, etc, and feel free to leave answers in the form of a sum. No calculators, books or

More information

Partition is reducible to P2 C max. c. P2 Pj = 1, prec Cmax is solvable in polynomial time. P Pj = 1, prec Cmax is NP-hard

Partition is reducible to P2 C max. c. P2 Pj = 1, prec Cmax is solvable in polynomial time. P Pj = 1, prec Cmax is NP-hard I. Minimizing Cmax (Nonpreemptive) a. P2 C max is NP-hard. Partition is reducible to P2 C max b. P Pj = 1, intree Cmax P Pj = 1, outtree Cmax are both solvable in polynomial time. c. P2 Pj = 1, prec Cmax

More information

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A CS1800 Discrete Structures Spring 2018 February 2018 CS1800 Discrete Structures Midterm Version A Instructions: 1. The exam is closed book and closed notes. You may not use a calculator or any other electronic

More information

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11 Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. V = {, 2, 3,,,, 7, 8 } E

More information

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Breadth First Search, Dijkstra s Algorithm for Shortest Paths CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth

More information

Advanced Combinatorial Optimization Updated February 18, Lecture 5. Lecturer: Michel X. Goemans Scribe: Yehua Wei (2009)

Advanced Combinatorial Optimization Updated February 18, Lecture 5. Lecturer: Michel X. Goemans Scribe: Yehua Wei (2009) 18.438 Advanced Combinatorial Optimization Updated February 18, 2012. Lecture 5 Lecturer: Michel X. Goemans Scribe: Yehua Wei (2009) In this lecture, we establish the connection between nowhere-zero k-flows

More information

Lecture 10 February 4, 2013

Lecture 10 February 4, 2013 UBC CPSC 536N: Sparse Approximations Winter 2013 Prof Nick Harvey Lecture 10 February 4, 2013 Scribe: Alexandre Fréchette This lecture is about spanning trees and their polyhedral representation Throughout

More information

ICS 252 Introduction to Computer Design

ICS 252 Introduction to Computer Design ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]

More information

arxiv: v1 [cs.ds] 2 Oct 2018

arxiv: v1 [cs.ds] 2 Oct 2018 Contracting to a Longest Path in H-Free Graphs Walter Kern 1 and Daniël Paulusma 2 1 Department of Applied Mathematics, University of Twente, The Netherlands w.kern@twente.nl 2 Department of Computer Science,

More information

Notes on the Matrix-Tree theorem and Cayley s tree enumerator

Notes on the Matrix-Tree theorem and Cayley s tree enumerator Notes on the Matrix-Tree theorem and Cayley s tree enumerator 1 Cayley s tree enumerator Recall that the degree of a vertex in a tree (or in any graph) is the number of edges emanating from it We will

More information

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source Shortest

More information

from notes written mostly by Dr. Matt Stallmann: All Rights Reserved

from notes written mostly by Dr. Matt Stallmann: All Rights Reserved CSC 505, Fall 000: Week 0 Objectives: understand problem complexity and classes defined by it understand relationships among decision, witness, evaluation, and optimization problems understand what it

More information

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10 Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 10 CSE 101: Design and analysis of algorithms Greedy algorithms Reading: Kleinberg and Tardos, sections 4.1, 4.2, and 4.3 Homework 4

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Fall 205 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 7 October 22, 205 Chandra & Manoj (UIUC) CS374 Fall 205 / 54 Part I Shortest Paths with

More information

Midterm Exam 2 Solutions

Midterm Exam 2 Solutions Algorithm Design and Analysis November 12, 2010 Pennsylvania State University CSE 565, Fall 2010 Professor Adam Smith Exam 2 Solutions Problem 1 (Miscellaneous). Midterm Exam 2 Solutions (a) Your friend

More information

CSE 591 Homework 3 Sample Solutions. Problem 1

CSE 591 Homework 3 Sample Solutions. Problem 1 CSE 591 Homework 3 Sample Solutions Problem 1 (a) Let p = max{1, k d}, q = min{n, k + d}, it suffices to find the pth and qth largest element of L and output all elements in the range between these two

More information

Approximation algorithms for cycle packing problems

Approximation algorithms for cycle packing problems Approximation algorithms for cycle packing problems Michael Krivelevich Zeev Nutov Raphael Yuster Abstract The cycle packing number ν c (G) of a graph G is the maximum number of pairwise edgedisjoint cycles

More information

More on NP and Reductions

More on NP and Reductions Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 501 Advanced Data

More information

Very few Moore Graphs

Very few Moore Graphs Very few Moore Graphs Anurag Bishnoi June 7, 0 Abstract We prove here a well known result in graph theory, originally proved by Hoffman and Singleton, that any non-trivial Moore graph of diameter is regular

More information

i times p(p(... (p( n))...) = n ki.

i times p(p(... (p( n))...) = n ki. Chapter 7 NP Completeness Exercise 7.1 Show that an algorithm that makes at most a constant number of calls to polynomial-time subroutines runs in polynomial time, but that a polynomial number of calls

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 8 Greedy Algorithms V Huffman Codes Adam Smith Review Questions Let G be a connected undirected graph with distinct edge weights. Answer true or false: Let e be the

More information

Data Structures and Algorithms (CSCI 340)

Data Structures and Algorithms (CSCI 340) University of Wisconsin Parkside Fall Semester 2008 Department of Computer Science Prof. Dr. F. Seutter Data Structures and Algorithms (CSCI 340) Homework Assignments The numbering of the problems refers

More information

Greedy Algorithms. Kleinberg and Tardos, Chapter 4

Greedy Algorithms. Kleinberg and Tardos, Chapter 4 Greedy Algorithms Kleinberg and Tardos, Chapter 4 1 Selecting breakpoints Road trip from Fort Collins to Durango on a given route. Fuel capacity = C. Goal: makes as few refueling stops as possible. Greedy

More information

A necessary and sufficient condition for the existence of a spanning tree with specified vertices having large degrees

A necessary and sufficient condition for the existence of a spanning tree with specified vertices having large degrees A necessary and sufficient condition for the existence of a spanning tree with specified vertices having large degrees Yoshimi Egawa Department of Mathematical Information Science, Tokyo University of

More information

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order? CS103 Handout 16 Fall 2011 November 4, 2011 Extra Practice Problems Many of you have expressed interest in additional practice problems to review the material from the first four weeks of CS103. This handout

More information

Lecture 4: NP and computational intractability

Lecture 4: NP and computational intractability Chapter 4 Lecture 4: NP and computational intractability Listen to: Find the longest path, Daniel Barret What do we do today: polynomial time reduction NP, co-np and NP complete problems some examples

More information

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source

More information

CS 170, Fall 1997 Second Midterm Professor Papadimitriou

CS 170, Fall 1997 Second Midterm Professor Papadimitriou CS 170, Fall 1997 Second Midterm Professor Papadimitriou Problem #1 (10 Points) Remember the change-maker problem: We are given k integers d 1,..., d k > 0 (the coin denominations) and an integer n. We

More information

UNIVERSITY OF YORK. MSc Examinations 2004 MATHEMATICS Networks. Time Allowed: 3 hours.

UNIVERSITY OF YORK. MSc Examinations 2004 MATHEMATICS Networks. Time Allowed: 3 hours. UNIVERSITY OF YORK MSc Examinations 2004 MATHEMATICS Networks Time Allowed: 3 hours. Answer 4 questions. Standard calculators will be provided but should be unnecessary. 1 Turn over 2 continued on next

More information

CSC 421: Algorithm Design & Analysis. Spring 2018

CSC 421: Algorithm Design & Analysis. Spring 2018 CSC 421: Algorithm Design & Analysis Spring 2018 Complexity & Computability complexity theory tractability, decidability P vs. NP, Turing machines NP-complete, reductions approximation algorithms, genetic

More information

CS281A/Stat241A Lecture 19

CS281A/Stat241A Lecture 19 CS281A/Stat241A Lecture 19 p. 1/4 CS281A/Stat241A Lecture 19 Junction Tree Algorithm Peter Bartlett CS281A/Stat241A Lecture 19 p. 2/4 Announcements My office hours: Tuesday Nov 3 (today), 1-2pm, in 723

More information

Greedy Algorithms My T. UF

Greedy Algorithms My T. UF Introduction to Algorithms Greedy Algorithms @ UF Overview A greedy algorithm always makes the choice that looks best at the moment Make a locally optimal choice in hope of getting a globally optimal solution

More information

Assignment 4. CSci 3110: Introduction to Algorithms. Sample Solutions

Assignment 4. CSci 3110: Introduction to Algorithms. Sample Solutions Assignment 4 CSci 3110: Introduction to Algorithms Sample Solutions Question 1 Denote the points by p 1, p 2,..., p n, ordered by increasing x-coordinates. We start with a few observations about the structure

More information

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February) Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should

More information

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

CSE 417. Chapter 4: Greedy Algorithms. Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. CSE 417 Chapter 4: Greedy Algorithms Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Greed is good. Greed is right. Greed works. Greed clarifies, cuts through,

More information

Packing and Covering Dense Graphs

Packing and Covering Dense Graphs Packing and Covering Dense Graphs Noga Alon Yair Caro Raphael Yuster Abstract Let d be a positive integer. A graph G is called d-divisible if d divides the degree of each vertex of G. G is called nowhere

More information

Exact Algorithms for Dominating Induced Matching Based on Graph Partition

Exact Algorithms for Dominating Induced Matching Based on Graph Partition Exact Algorithms for Dominating Induced Matching Based on Graph Partition Mingyu Xiao School of Computer Science and Engineering University of Electronic Science and Technology of China Chengdu 611731,

More information

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 3 Luca Trevisan August 31, 2017

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 3 Luca Trevisan August 31, 2017 U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 3 Luca Trevisan August 3, 207 Scribed by Keyhan Vakil Lecture 3 In which we complete the study of Independent Set and Max Cut in G n,p random graphs.

More information

Copyright 2013 Springer Science+Business Media New York

Copyright 2013 Springer Science+Business Media New York Meeks, K., and Scott, A. (2014) Spanning trees and the complexity of floodfilling games. Theory of Computing Systems, 54 (4). pp. 731-753. ISSN 1432-4350 Copyright 2013 Springer Science+Business Media

More information

Fall 2017 November 10, Written Homework 5

Fall 2017 November 10, Written Homework 5 CS1800 Discrete Structures Profs. Aslam, Gold, & Pavlu Fall 2017 November 10, 2017 Assigned: Mon Nov 13 2017 Due: Wed Nov 29 2017 Instructions: Written Homework 5 The assignment has to be uploaded to blackboard

More information

(c) Give a proof of or a counterexample to the following statement: (3n 2)= n(3n 1) 2

(c) Give a proof of or a counterexample to the following statement: (3n 2)= n(3n 1) 2 Question 1 (a) Suppose A is the set of distinct letters in the word elephant, B is the set of distinct letters in the word sycophant, C is the set of distinct letters in the word fantastic, and D is the

More information

CMPSCI611: The Matroid Theorem Lecture 5

CMPSCI611: The Matroid Theorem Lecture 5 CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting

More information

besides your solutions of these problems. 1 1 We note, however, that there will be many factors in the admission decision

besides your solutions of these problems. 1 1 We note, however, that there will be many factors in the admission decision The PRIMES 2015 Math Problem Set Dear PRIMES applicant! This is the PRIMES 2015 Math Problem Set. Please send us your solutions as part of your PRIMES application by December 1, 2015. For complete rules,

More information

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming Algorithms and Theory of Computation Lecture 9: Dynamic Programming Xiaohui Bei MAS 714 September 10, 2018 Nanyang Technological University MAS 714 September 10, 2018 1 / 21 Recursion in Algorithm Design

More information

Climbing an Infinite Ladder

Climbing an Infinite Ladder Section 5.1 Section Summary Mathematical Induction Examples of Proof by Mathematical Induction Mistaken Proofs by Mathematical Induction Guidelines for Proofs by Mathematical Induction Climbing an Infinite

More information

Geometric Steiner Trees

Geometric Steiner Trees Geometric Steiner Trees From the book: Optimal Interconnection Trees in the Plane By Marcus Brazil and Martin Zachariasen Part 3: Computational Complexity and the Steiner Tree Problem Marcus Brazil 2015

More information

Aditya Bhaskara CS 5968/6968, Lecture 1: Introduction and Review 12 January 2016

Aditya Bhaskara CS 5968/6968, Lecture 1: Introduction and Review 12 January 2016 Lecture 1: Introduction and Review We begin with a short introduction to the course, and logistics. We then survey some basics about approximation algorithms and probability. We also introduce some of

More information