Activity selection. Goal: Select the largest possible set of nonoverlapping (mutually compatible) activities.
|
|
- Aron Miller
- 5 years ago
- Views:
Transcription
1 Greedy Algorithm 1
2 Introduction Similar to dynamic programming. Used for optimization problems. Not always yield an optimal solution. Make choice for the one looks best right now. Make a locally optimal choice in hope of getting a globally optimal solution. 2
3 Activity selection n activities require exclusive use of a common resource. For example, scheduling the use of a classroom. Set of activities S = {a 1..., a n }. a 1 needs resource during period [s i, f i ), which is a half-open interval, where s i = start time and f i = finish time. Goal: Select the largest possible set of nonoverlapping (mutually compatible) activities. Note: Could have many other objectives: Schedule room for longest time. Maximize income rental fees. 3
4 Activity selection Example: S sorted by finish time i s i f i Maximum-size mutually compatible set: {a 1, a 4, a 8, a 11 }. Not unique: also {a 2, a 4, a 9, a 11 }. 4
5 Activity selection Optimal substructure of activity selection S ij = {a k S : f i s k f k s j } = activities that start after a i finishes and finish before a j starts. a i f f i s k k s j a k a j 5
6 Activity selection Activities in S ij are compatible with all activities that finish by f i, and all activities that start no earlier than s j. To represent the entire problem, add fictitious activities: a 0 = [, 0) a n+1 = [, + 1 ) we don t care about and + 1. Then S = S 0,n+1. Range for S ij is 0 i, j n+1. 6
7 Activity selection Assume that activities are sorted by monotonically increasing finish time: f 0 f 1 f 2 f n f n+1. Then i j S ij = Ø. If there exists a k S ij : f i s k < f k s j < f j f i < f j. But i j f i f j. Contradiction. So only need to worry about S ij with 0 i < j n + 1. All other S ij are Ø. 7
8 Activity selection Suppose that a solution to S ij includes a k. Have 2 subproblems: S ik (start after a i finishes, finish before a k starts) S kj (start after a k finishes, finish before a a j starts) Solution to S ij is (solution to S ik ) {a k } ( solution to S kj ). Since a k is in neither subproblem, and the subproblems are disjoint, solution to S = solution to S ik solution to S kj. 8
9 Activity selection If an optimal solution to S ij includes a k, then the solutions to S ik and S kj used within this solution must be optimal as well. Use the usual cut-and-paste argument. Let A ij = optimal solution to S ij. So A ij = A ik {a k } A kj, assuming: S ij is nonempty, and we know a k. 9
10 Activity selection Recursive solution to activity selection c[i, j]=size of maximum-size subset of mutually compatible activities in S ij. i j S ij = Ø c[i, j] = 0. If S ij Ø, suppose we know that a k is in the subset. Then c[i, j] = c[i, k] c[k, j]. But of course we don t know which k to use, and so C[i, j] = { 0 if S ij = Ø, max {c[i, k] + c[k, j] + 1} if S ij Ø. a k S ij i < k< j 10
11 Theorem Activity selection Let S ij Ø, and let a m be the activity in S ij with the earliest finish time: f m = min {f k : a k S ij }. Then: 1. a m is used in some maximum-size subset of mutually compatible activities of S ij. 2. S im = Ø, so that choosing a m leaves S mj as the only nonempty subproblem. 11
12 Proof Activity selection 2. Suppose there is some a k S im. Then f i s k f k s m f m f k f m. Then a k S ij and it has an earlier finish than f m, which contradicts our choice of a m. Therefore, there is no a k S im S im. 1. Let A ij be a maximum-size subset of mutually compatible activities in S ij. Order activities in A ij in monotonically increasing order of finish time. Let a k be the first activity in A ij. If a k a m, done (a m is used in a maximum-size subset). Otherwise, construct A ij A ij {a k } {a m } (replace a k by a m ) 12
13 Activity selection Claim Activities in A ' ij are disjoint. Proof Activities in A ij are disjoint, a k is the first activity in A ij to finish, f m f k (so a m doesn t overlap with anything else in A' ij ). (claim) Since A' ij = A ij and A ij is a maximum-size subset, so is A' ij. (theorem) 13
14 Activity selection This is great: before theorem after theorem # of subproblems in optimal solution 2 1 # of choices to consider j i 1 1 Now we can solve top down: To solve a problem S ij, Choose a m S ij with earliest finish time: the greedy choice. Then solve S mj. 14
15 Activity selection What are the subproblems? Original problem is S 0,n+1. Suppose our first choice is a m1. Then next subproblem is S m1,n+1. Suppose next choice is a m2. Next subproblem is S m2,n+1. And so on. Each subproblem is S mi,n+1, i.e., the last activities to finish. And the subproblems chosen have finish times that increase. Therefore, we can consider each activity just once, in monotonically increasing order of finish time. 15
16 Activity selection Easy recursive algorithm: Assumes activities already sorted by monotonically increasing finish time. (If not, then sort in O (n lg n) time.) Return an optimal solution for S i,n+1 : REC-ACTIVITY-SELECTOR(s, f, i, n) m i + 1 while m n and s m < f i Find first activity in S i,n+1. do m m + 1 If m n then return {a m } REC-ACTIVITY-SELECTOR(s, f, m, n) else return 16
17 Activity selection Initial call: REC-ACTIVITY-SELECTOR(s, f, 0, n) Idea: The while loop checks a i+1, a i+2,, a n until it finds an activity a m that is compatible with a i (need s m f i ). If the loop terminates because a m is found (m n), then recursively solve S m,n+1, and return this solution, along with a m. If the loop never finds a compatible a m (m > n), then just return empty set. Go through example given earlier. Should get {a 1, a 4, a 8, a 11 }. Time: Θ (n) each activity examined exactly once. 17
18 k s k f k 0-0 a a 0 a 1 m = 1 R E C U R SI V E - A C T I V I T Y - SE L E C T O R (s, f, 0, 11 ) a 1 a 2 R E C U R SI V E - A C T I V I T Y - SE L E C T O R (s, f, 1, 11 ) a 3 a a 1 a 4 m = a 5 R E C U R SI V E - A C T I V I T Y - SE L E C T O R (s, f, 4, 11 ) a 1 a a 6 a 1 a a 7 a 1 a a 1 a 4 a 8 m = R E C U R SI V E - A C T I V I T Y - SE L E C T O R (s, f, 8, 11 ) a 9 a 1 a 4 a 8 a a 1 a 4 a a 11 a 1 a 4 a 8 m = R E C U R SI V E - A C T I V I T Y - SE L E C T O R (s, f, 11, 11 ) a 1 a 4 a 8 a time
19 Can make this iterative. Activity selection GREEDY-ACTIVITY-SELECTOR(s, f, n) A {a 1 } i 1 for m 2 to n do if s m f i then A A {a m } i m a i is most recent addition to A. return A Go through example given earlier. Should again get {a 1, a 4, a 8, a 11 }. Time: Θ (n). 19
20 Greedy strategy The choice that seems best at the moment is the one we go with. What did we do for activity selection? 1. Determine the optimal substructure. 2. Develop a recursive solution. 3. Prove that at any stage of recursion, one of the optimal choices is the greedy choice. Therefore, it s always safe to make the greedy choice. 4. Show that all but one of the subproblems resulting from the greedy choice are empty. 5. Develop a recursive greedy algorithm. 6. Convert it to an iterative algorithm. 20
21 Greedy strategy Typical streamlined steps: 1. Cast the optimization problem as one in which we make a choice and are left with one subproblem to solve. 2. Prove that there s always an optimal solution that makes the greedy choice, so that the greedy choice is always safe. 3. Show that greedy choice and optimal solution to subproblem optimal solution to the problem. No general way to tell if a greedy algorithm is optimal, but two key ingredients are 1. greedy-choice property and 2. optimal substructure. 21
22 Greedy strategy Dynamic programming: Make a choice at each step. Choice depends on knowing optimal solutions to subproblems. Solve subproblems first. Solve bottom-up. Greedy: Make a choice at each step. Make the choice before solving the subproblems. Solve top-down 22
23 Greedy strategy Greedy vs. dynamic programming The knapsack problem is a good example of the difference. 0-1 knapsack problem: n items. Item i is worth $v i, weighs w i pounds. Find a most valuable subset of items with total weight W. Have to either take an item or not take it can t take part of it. 23
24 Greedy strategy Fractional knapsack problem: Like the 0-1 kanpsack problem, but can take fraction of an item. Both have optimal substructure. But the fractional kanpsack problem has the greedy-choice property, and the 0-1 knapsack problem does not have greedy-choice that returns optimal solution. To solve the fractional problem, rank items by value/weight: v i /w i. Let v i /w i v i+1 /w i+1 for all i. 24
25 Greedy strategy Fractional knapsack (v, w, W) load 0 i 1 while load W and i n do if w i W load then take all of item i else take (W load)/w i of item i add what was taken to load i i + 1 move to the next valuable item. Taking the items in order of greatest value per pound yields an optimal solution. 25
26 Greedy strategy Time: O (n lg n) to sort, O (n) thereafter Greedy doesn t work for the 0-1 knapsack problem. Might get empty space, which lowers the average value per pound of the items taken. i v i w i v i /w i W = 50 26
27 Greedy strategy Greedy solution: Take items 1 and 2. value = 160, weight = 30. Have 20 pounds of capacity left over. 0-1 knapsack problem can t be solved w/ greedy strategy. (i.e., the optimal solution can t be obtained w/ greedy strategy) Fraction knapsack problem can be solved w/ greedy strategy by adding 20 pounds (2/3 of item 3) 4 = $80 value. Optimal solution (for 0-1 knapsack w/o greedy strategy): Take items 2 and 3. value = 220, weight = 50. No leftover capacity. 27
Lecture 9. Greedy Algorithm
Lecture 9. Greedy Algorithm T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2018
More informationGreedy 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 informationKnapsack and Scheduling Problems. The Greedy Method
The Greedy Method: Knapsack and Scheduling Problems The Greedy Method 1 Outline and Reading Task Scheduling Fractional Knapsack Problem The Greedy Method 2 Elements of Greedy Strategy An greedy algorithm
More informationCS583 Lecture 11. Many slides here are based on D. Luebke slides. Review: Dynamic Programming
// CS8 Lecture Jana Kosecka Dynamic Programming Greedy Algorithms Many slides here are based on D. Luebke slides Review: Dynamic Programming A meta-technique, not an algorithm (like divide & conquer) Applicable
More informationCSE 421 Dynamic Programming
CSE Dynamic Programming Yin Tat Lee Weighted Interval Scheduling Interval Scheduling Job j starts at s(j) and finishes at f j and has weight w j Two jobs compatible if they don t overlap. Goal: find maximum
More informationCS Lunch. Dynamic Programming Recipe. 2 Midterm 2! Slides17 - Segmented Least Squares.key - November 16, 2016
CS Lunch 1 Michelle Oraa Ali Tien Dao Vladislava Paskova Nan Zhuang Surabhi Sharma Wednesday, 12:15 PM Kendade 307 2 Midterm 2! Monday, November 21 In class Covers Greedy Algorithms Closed book Dynamic
More informationDynamic Programming( Weighted Interval Scheduling)
Dynamic Programming( Weighted Interval Scheduling) 17 November, 2016 Dynamic Programming 1 Dynamic programming algorithms are used for optimization (for example, finding the shortest path between two points,
More informationGeneral Methods for Algorithm Design
General Methods for Algorithm Design 1. Dynamic Programming Multiplication of matrices Elements of the dynamic programming Optimal triangulation of polygons Longest common subsequence 2. Greedy Methods
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 5 Greedy Algorithms Interval Scheduling Interval Partitioning Guest lecturer: Martin Furer Review In a DFS tree of an undirected graph, can there be an edge (u,v)
More informationCSE 421 Weighted Interval Scheduling, Knapsack, RNA Secondary Structure
CSE Weighted Interval Scheduling, Knapsack, RNA Secondary Structure Shayan Oveis haran Weighted Interval Scheduling Interval Scheduling Job j starts at s(j) and finishes at f j and has weight w j Two jobs
More informationDAA Unit- II Greedy and Dynamic Programming. By Mrs. B.A. Khivsara Asst. Professor Department of Computer Engineering SNJB s KBJ COE, Chandwad
DAA Unit- II Greedy and Dynamic Programming By Mrs. B.A. Khivsara Asst. Professor Department of Computer Engineering SNJB s KBJ COE, Chandwad 1 Greedy Method 2 Greedy Method Greedy Principal: are typically
More informationDynamic Programming: Interval Scheduling and Knapsack
Dynamic Programming: Interval Scheduling and Knapsack . Weighted Interval Scheduling Weighted Interval Scheduling Weighted interval scheduling problem. Job j starts at s j, finishes at f j, and has weight
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 6 Greedy Algorithms Interval Scheduling Interval Partitioning Scheduling to Minimize Lateness Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine,
More informationCSE 421 Greedy Algorithms / Interval Scheduling
CSE 421 Greedy Algorithms / Interval Scheduling Yin Tat Lee 1 Interval Scheduling Job j starts at s(j) and finishes at f(j). Two jobs compatible if they don t overlap. Goal: find maximum subset of mutually
More informationCMSC 451: Lecture 7 Greedy Algorithms for Scheduling Tuesday, Sep 19, 2017
CMSC CMSC : Lecture Greedy Algorithms for Scheduling Tuesday, Sep 9, 0 Reading: Sects.. and. of KT. (Not covered in DPV.) Interval Scheduling: We continue our discussion of greedy algorithms with a number
More information6. DYNAMIC PROGRAMMING I
6. DYNAMIC PROGRAMMING I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013
More informationCS 561, Lecture: Greedy Algorithms. Jared Saia University of New Mexico
CS 561, Lecture: Greedy Algorithms Jared Saia University of New Mexico Outline Greedy Algorithm Intro Activity Selection Knapsack 1 Greedy Algorithms Greed is Good - Michael Douglas in Wall Street A greedy
More informationDynamic Programming. Cormen et. al. IV 15
Dynamic Programming Cormen et. al. IV 5 Dynamic Programming Applications Areas. Bioinformatics. Control theory. Operations research. Some famous dynamic programming algorithms. Unix diff for comparing
More informationToday s Outline. CS 561, Lecture 15. Greedy Algorithms. Activity Selection. Greedy Algorithm Intro Activity Selection Knapsack
Today s Outline CS 561, Lecture 15 Jared Saia University of New Mexico Greedy Algorithm Intro Activity Selection Knapsack 1 Greedy Algorithms Activity Selection Greed is Good - Michael Douglas in Wall
More informationMaximum sum contiguous subsequence Longest common subsequence Matrix chain multiplication All pair shortest path Kna. Dynamic Programming
Dynamic Programming Arijit Bishnu arijit@isical.ac.in Indian Statistical Institute, India. August 31, 2015 Outline 1 Maximum sum contiguous subsequence 2 Longest common subsequence 3 Matrix chain multiplication
More informationGreedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later:
October 5, 017 Greedy Chapters 5 of Dasgupta et al. 1 Activity selection Fractional knapsack Huffman encoding Later: Outline Dijkstra (single source shortest path) Prim and Kruskal (minimum spanning tree)
More informationLecture 6: Greedy Algorithms I
COMPSCI 330: Design and Analysis of Algorithms September 14 Lecturer: Rong Ge Lecture 6: Greedy Algorithms I Scribe: Fred Zhang 1 Overview In this lecture, we introduce a new algorithm design technique
More informationDynamic Programming. Credits: Many of these slides were originally authored by Jeff Edmonds, York University. Thanks Jeff!
Dynamic Programming Credits: Many of these slides were originally authored by Jeff Edmonds, York University. Thanks Jeff! Optimization Problems For most, the best known algorithm runs in exponential time.
More informationCS 6901 (Applied Algorithms) Lecture 3
CS 6901 (Applied Algorithms) Lecture 3 Antonina Kolokolova September 16, 2014 1 Representative problems: brief overview In this lecture we will look at several problems which, although look somewhat similar
More informationWeighted Activity Selection
Weighted Activity Selection Problem This problem is a generalization of the activity selection problem that we solvd with a greedy algorithm. Given a set of activities A = {[l, r ], [l, r ],..., [l n,
More informationCSE 202 Dynamic Programming II
CSE 202 Dynamic Programming II Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally,
More informationDynamic Programming (CLRS )
Dynamic Programming (CLRS.-.) Today we discuss a technique called dynamic programming. It is neither especially dynamic nor especially programming related. We will discuss dynamic programming by looking
More informationChapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and
More informationM17 MAT25-21 HOMEWORK 6
M17 MAT25-21 HOMEWORK 6 DUE 10:00AM WEDNESDAY SEPTEMBER 13TH 1. To Hand In Double Series. The exercises in this section will guide you to complete the proof of the following theorem: Theorem 1: Absolute
More informationCS 161: Design and Analysis of Algorithms
CS 161: Design and Analysis of Algorithms Greedy Algorithms 3: Minimum Spanning Trees/Scheduling Disjoint Sets, continued Analysis of Kruskal s Algorithm Interval Scheduling Disjoint Sets, Continued Each
More informationCSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD
Course Overview Material that will be covered in the course: Basic graph algorithms Algorithm Design Techniques Greedy Algorithms Divide and Conquer Dynamic Programming Network Flows Computational intractability
More informationCSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo
CSE 431/531: Analysis of Algorithms Dynamic Programming Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Paradigms for Designing Algorithms Greedy algorithm Make a
More informationCSE 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 informationDynamic Programming ACM Seminar in Algorithmics
Dynamic Programming ACM Seminar in Algorithmics Marko Genyk-Berezovskyj berezovs@fel.cvut.cz Tomáš Tunys tunystom@fel.cvut.cz CVUT FEL, K13133 February 27, 2013 Problem: Longest Increasing Subsequence
More informationif the two intervals overlap at most at end
Activity Selection Given a set of activities represented by intervals (s i f i ), i =1 ::: n. To select a maximum number of compatible intervals (activities). Two activities (s i f i ) and (s j f j ) are
More informationAlgorithm 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 information6. DYNAMIC PROGRAMMING I
6. DYNAMIC PRORAMMIN I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos
More informationGreedy 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 information1 Basic Definitions. 2 Proof By Contradiction. 3 Exchange Argument
1 Basic Definitions A Problem is a relation from input to acceptable output. For example, INPUT: A list of integers x 1,..., x n OUTPUT: One of the three smallest numbers in the list An algorithm A solves
More informationComputer Science & Engineering 423/823 Design and Analysis of Algorithms
Computer Science & Engineering 423/823 Design and Analysis of s Lecture 09 Dynamic Programming (Chapter 15) Stephen Scott (Adapted from Vinodchandran N. Variyam) 1 / 41 Spring 2010 Dynamic programming
More informationComputer Science & Engineering 423/823 Design and Analysis of Algorithms
Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 03 Dynamic Programming (Chapter 15) Stephen Scott and Vinodchandran N. Variyam sscott@cse.unl.edu 1/44 Introduction Dynamic
More informationChapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and
More informationThe Greedy Method. Design and analysis of algorithms Cs The Greedy Method
Design and analysis of algorithms Cs 3400 The Greedy Method 1 Outline and Reading The Greedy Method Technique Fractional Knapsack Problem Task Scheduling 2 The Greedy Method Technique The greedy method
More information(a) Write a greedy O(n log n) algorithm that, on input S, returns a covering subset C of minimum size.
Esercizi su Greedy Exercise 1.1 Let S = {[a 1, b 1 ], [a 2, b 2 ],..., [a n, b n ]} be a set of closed intervals on the real line. We say that C S is a covering subset for S if, for any interval [a, b]
More informationCS 6783 (Applied Algorithms) Lecture 3
CS 6783 (Applied Algorithms) Lecture 3 Antonina Kolokolova January 14, 2013 1 Representative problems: brief overview of the course In this lecture we will look at several problems which, although look
More informationMidterm 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/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17
601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 12.1 Introduction Today we re going to do a couple more examples of dynamic programming. While
More informationWhat is Dynamic Programming
What is Dynamic Programming Like DaC, Greedy algorithms, Dynamic Programming is another useful method for designing efficient algorithms. Why the name? Eye of the Hurricane: An Autobiography - A quote
More informationCS60007 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 informationCopyright 2000, Kevin Wayne 1
//8 Fast Integer Division Too (!) Schönhage Strassen algorithm CS 8: Algorithm Design and Analysis Integer division. Given two n-bit (or less) integers s and t, compute quotient q = s / t and remainder
More informationDynamic Programming 1
Dynamic Programming 1 lgorithmic Paradigms Divide-and-conquer. Break up a problem into two sub-problems, solve each sub-problem independently, and combine solution to sub-problems to form solution to original
More informationLecture 13: Dynamic Programming Part 2 10:00 AM, Feb 23, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 13: Dynamic Programming Part 2 10:00 AM, Feb 23, 2018 Contents 1 Holidays 1 1.1 Halloween..........................................
More informationCS 580: Algorithm Design and Analysis
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 208 Announcement: Homework 3 due February 5 th at :59PM Final Exam (Tentative): Thursday, May 3 @ 8AM (PHYS 203) Recap: Divide
More informationChapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.
Chapter 11 Approximation Algorithms Slides by Kevin Wayne. Copyright @ 2005 Pearson-Addison Wesley. All rights reserved. 1 Approximation Algorithms Q. Suppose I need to solve an NP-hard problem. What should
More informationCS 374: Algorithms & Models of Computation, Spring 2017 Greedy Algorithms Lecture 19 April 4, 2017 Chandra Chekuri (UIUC) CS374 1 Spring / 1
CS 374: Algorithms & Models of Computation, Spring 2017 Greedy Algorithms Lecture 19 April 4, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 1 Part I Greedy Algorithms: Tools and Techniques Chandra
More informationOutline / Reading. Greedy Method as a fundamental algorithm design technique
Greedy Method Outline / Reading Greedy Method as a fundamental algorithm design technique Application to problems of: Making change Fractional Knapsack Problem (Ch. 5.1.1) Task Scheduling (Ch. 5.1.2) Minimum
More informationMat 3770 Bin Packing or
Basic Algithm Spring 2014 Used when a problem can be partitioned into non independent sub problems Basic Algithm Solve each sub problem once; solution is saved f use in other sub problems Combine solutions
More informationThis means that we can assume each list ) is
This means that we can assume each list ) is of the form ),, ( )with < and Since the sizes of the items are integers, there are at most +1pairs in each list Furthermore, if we let = be the maximum possible
More informationCSE 202 Homework 4 Matthias Springer, A
CSE 202 Homework 4 Matthias Springer, A99500782 1 Problem 2 Basic Idea PERFECT ASSEMBLY N P: a permutation P of s i S is a certificate that can be checked in polynomial time by ensuring that P = S, and
More informationOn Two Class-Constrained Versions of the Multiple Knapsack Problem
On Two Class-Constrained Versions of the Multiple Knapsack Problem Hadas Shachnai Tami Tamir Department of Computer Science The Technion, Haifa 32000, Israel Abstract We study two variants of the classic
More informationCOSC 341: Lecture 25 Coping with NP-hardness (2)
1 Introduction Figure 1: Famous cartoon by Garey and Johnson, 1979 We have seen the definition of a constant factor approximation algorithm. The following is something even better. 2 Approximation Schemes
More informationCS483 Design and Analysis of Algorithms
CS483 Design and Analysis of Algorithms Lectures 15-16 Dynamic Programming Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments
More informationChapter 8 Dynamic Programming
Chapter 8 Dynamic Programming Copyright 007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by
More informationChapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes
More information6. DYNAMIC PROGRAMMING I
lgorithmic paradigms 6. DYNMI PRORMMIN I weighted interval scheduling segmented least squares knapsack problem RN secondary structure reedy. Build up a solution incrementally, myopically optimizing some
More informationDynamic Programming. Weighted Interval Scheduling. Algorithmic Paradigms. Dynamic Programming
lgorithmic Paradigms Dynamic Programming reed Build up a solution incrementally, myopically optimizing some local criterion Divide-and-conquer Break up a problem into two sub-problems, solve each sub-problem
More informationDynamic Programming. Data Structures and Algorithms Andrei Bulatov
Dynamic Programming Data Structures and Algorithms Andrei Bulatov Algorithms Dynamic Programming 18-2 Weighted Interval Scheduling Weighted interval scheduling problem. Instance A set of n jobs. Job j
More information- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs
LP-Duality ( Approximation Algorithms by V. Vazirani, Chapter 12) - Well-characterized problems, min-max relations, approximate certificates - LP problems in the standard form, primal and dual linear programs
More information1 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 informationEECS 477: Introduction to algorithms. Lecture 12
EECS 477: Introduction to algorithms. Lecture 12 Prof. Igor Guskov guskov@eecs.umich.edu October 17, 2002 1 Lecture outline: greedy algorithms II Knapsack Scheduling minimizing time with deadlines 2 Greedy
More informationGreedy Homework Problems
CS 1510 Greedy Homework Problems 1. Consider the following problem: INPUT: A set S = {(x i, y i ) 1 i n} of intervals over the real line. OUTPUT: A maximum cardinality subset S of S such that no pair of
More informationLecture 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 informationCS 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 informationProof methods and greedy algorithms
Proof methods and greedy algorithms Magnus Lie Hetland Lecture notes, May 5th 2008 1 Introduction This lecture in some ways covers two separate topics: (1) how to prove algorithms correct, in general,
More informationIntroduction. I Dynamic programming is a technique for solving optimization problems. I Key element: Decompose a problem into subproblems, solve them
ntroduction Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 03 Dynamic Programming (Chapter 15) Stephen Scott and Vinodchandran N. Variyam Dynamic programming is a technique
More informationChapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Algorithmic Paradigms Greed. Build up a solution incrementally, myopically optimizing
More information1 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)
CME 305: Discrete Mathematics and Algorithms Instructor: Reza Zadeh (rezab@stanford.edu) Final Review Session 03/20/17 1. Let G = (V, E) be an unweighted, undirected graph. Let λ 1 be the maximum eigenvalue
More informationCS 170 Algorithms Fall 2014 David Wagner MT2
CS 170 Algorithms Fall 2014 David Wagner MT2 PRINT your name:, (last) SIGN your name: (first) Your Student ID number: Your Unix account login: cs170- The room you are sitting in right now: Name of the
More informationRecap & Interval Scheduling
Lecture 2 Recap & Interval Scheduling Supplemental reading in CLRS: Section 6.; Section 4.4 2. Recap of Median Finding Like MERGE-SORT, the median-of-medians algorithm SELECT calls itself recursively,
More informationAssignment 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 informationAlgorithms 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 informationRecursion: Introduction and Correctness
Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and
More informationDynamic Programming. Prof. S.J. Soni
Dynamic Programming Prof. S.J. Soni Idea is Very Simple.. Introduction void calculating the same thing twice, usually by keeping a table of known results that fills up as subinstances are solved. Dynamic
More informationChapter 6. Dynamic Programming. CS 350: Winter 2018
Chapter 6 Dynamic Programming CS 350: Winter 2018 1 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer. Break up a problem into
More information1 Assembly Line Scheduling in Manufacturing Sector
Indian Institute of Information Technology Design and Manufacturing, Kancheepuram, Chennai 600 27, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 209T Design and Analysis
More informationWeek 5: Quicksort, Lower bound, Greedy
Week 5: Quicksort, Lower bound, Greedy Agenda: Quicksort: Average case Lower bound for sorting Greedy method 1 Week 5: Quicksort Recall Quicksort: The ideas: Pick one key Compare to others: partition into
More informationRECOVERY OF NON-LINEAR CONDUCTIVITIES FOR CIRCULAR PLANAR GRAPHS
RECOVERY OF NON-LINEAR CONDUCTIVITIES FOR CIRCULAR PLANAR GRAPHS WILL JOHNSON Abstract. We consider the problem of recovering nonlinear conductances in a circular planar graph. If the graph is critical
More informationCSE 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 informationChapter 8 Dynamic Programming
Chapter 8 Dynamic Programming Copyright 2007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by
More informationCS 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/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 10/31/16
60.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 0/3/6 6. Introduction We talked a lot the last lecture about greedy algorithms. While both Prim
More informationCommon-Deadline Lazy Bureaucrat Scheduling Problems
Common-Deadline Lazy Bureaucrat Scheduling Problems Behdad Esfahbod, Mohammad Ghodsi, and Ali Sharifi Computer Engineering Department Sharif University of Technology, Tehran, Iran, {behdad,ghodsi}@sharif.edu,
More informationGreedy vs Dynamic Programming Approach
Greedy vs Dynamic Programming Approach Outline Compare the methods Knapsack problem Greedy algorithms for 0/1 knapsack An approximation algorithm for 0/1 knapsack Optimal greedy algorithm for knapsack
More informationCS 598RM: Algorithmic Game Theory, Spring Practice Exam Solutions
CS 598RM: Algorithmic Game Theory, Spring 2017 1. Answer the following. Practice Exam Solutions Agents 1 and 2 are bargaining over how to split a dollar. Each agent simultaneously demands share he would
More informationDiscrete Mathematics: Logic. Discrete Mathematics: Lecture 17. Recurrence
Discrete Mathematics: Logic Discrete Mathematics: Lecture 17. Recurrence greedy algorithm greedy algorithm makes the best choice at each step (locally optimal solution) according to a specified criterion
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms CSE 5311 Lecture 22 All-Pairs Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 All Pairs
More informationPreview 11/1/2017. Greedy Algorithms. Coin Change. Coin Change. Coin Change. Coin Change. Greedy algorithms. Greedy Algorithms
Preview Greed Algorithms Greed Algorithms Coin Chnge Huffmn Code Greed lgorithms end to e simple nd strightforwrd. Are often used to solve optimiztion prolems. Alws mke the choice tht looks est t the moment,
More informationLecture 13. More dynamic programming! Longest Common Subsequences, Knapsack, and (if time) independent sets in trees.
Lecture 13 More dynamic programming! Longest Common Subsequences, Knapsack, and (if time) independent sets in trees. Announcements HW5 due Friday! HW6 released Friday! Last time Not coding in an action
More informationLecture 7: Dynamic Programming I: Optimal BSTs
5-750: Graduate Algorithms February, 06 Lecture 7: Dynamic Programming I: Optimal BSTs Lecturer: David Witmer Scribes: Ellango Jothimurugesan, Ziqiang Feng Overview The basic idea of dynamic programming
More informationTheoretical Computer Science
Theoretical Computer Science 411 (010) 417 44 Contents lists available at ScienceDirect Theoretical Computer Science journal homepage: wwwelseviercom/locate/tcs Resource allocation with time intervals
More information