Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math.

Slides:



Advertisements
Similar presentations
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Advertisements

Greedy Algorithms.
Bipartite Matching, Extremal Problems, Matrix Tree Theorem.
Greedy Algorithms Greed is good. (Some of the time)
Analysis of Algorithms
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
Greedy Algorithms Be greedy! always make the choice that looks best at the moment. Local optimization. Not always yielding a globally optimal solution.
Greedy Algorithms Basic idea Connection to dynamic programming
Greedy Algorithms Basic idea Connection to dynamic programming Proof Techniques.
Great Theoretical Ideas in Computer Science.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Dynamic Programming Technique. D.P.2 The term Dynamic Programming comes from Control Theory, not computer science. Programming refers to the use of tables.
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Greedy Algorithms Reading Material: –Alsuwaiyel’s Book: Section 8.1 –CLR Book (2 nd Edition): Section 16.1.
Greedy Algorithms CIS 606 Spring Greedy Algorithms Similar to dynamic programming. Used for optimization problems. Idea – When we have a choice.
Week 2: Greedy Algorithms
David Luebke 1 8/23/2015 CS 332: Algorithms Greedy Algorithms.
Called as the Interval Scheduling Problem. A simpler version of a class of scheduling problems. – Can add weights. – Can add multiple resources – Can ask.
Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2004 Simonas Šaltenis E1-215b
CSC 413/513: Intro to Algorithms Greedy Algorithms.
ACM programming contest Introduction + Recursion.
Greedy Methods and Backtracking Dr. Marina Gavrilova Computer Science University of Calgary Canada.
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
CSCI 256 Data Structures and Algorithm Analysis Lecture 6 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
Greedy Algorithms BIL741: Advanced Analysis of Algorithms I (İleri Algoritma Çözümleme I)1.
CS 3343: Analysis of Algorithms Lecture 19: Introduction to Greedy Algorithms.
1 Algorithms CSCI 235, Fall 2015 Lecture 29 Greedy Algorithms.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 17.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Greedy Algorithms Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
Greedy Algorithms General principle of greedy algorithm
Greedy Algorithms.
Greedy algorithms: CSC317
Greedy Algorithms.
Algorithm Design Methods
Weighted Interval Scheduling
CS 3343: Analysis of Algorithms
Merge Sort 7/29/ :21 PM The Greedy Method The Greedy Method.
Design & Analysis of Algorithm Greedy Algorithm
Greedy Algorithms Basic idea Connection to dynamic programming
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Presented by Po-Chuan & Chen-Chen 2016/03/08
Algorithm Design Methods
CS200: Algorithm Analysis
ICS 353: Design and Analysis of Algorithms
CS 3343: Analysis of Algorithms
Merge Sort 11/28/2018 2:18 AM The Greedy Method The Greedy Method.
The Greedy Method Spring 2007 The Greedy Method Merge Sort
Merge Sort 11/28/2018 8:16 AM The Greedy Method The Greedy Method.
Greedy Algorithm Enyue (Annie) Lu.
Lecture 11 Overview Self-Reducibility.
Advanced Algorithms Analysis and Design
Greedy Algorithms.
Advanced Algorithms Analysis and Design
Merge Sort 1/17/2019 3:11 AM The Greedy Method The Greedy Method.
Richard Anderson Lecture 6 Greedy Algorithms
Richard Anderson Autumn 2016 Lecture 7
Richard Anderson Lecture 7 Greedy Algorithms
Algorithms CSCI 235, Spring 2019 Lecture 29 Greedy Algorithms
Greedy Algorithms Comp 122, Spring 2004.
Algorithm Design Techniques Greedy Approach vs Dynamic Programming
Algorithm Design Methods
Richard Anderson Winter 2019 Lecture 7
Merge Sort 5/2/2019 7:53 PM The Greedy Method The Greedy Method.
Advance Algorithm Dynamic Programming
Algorithm Design Methods
Richard Anderson Autumn 2019 Lecture 7
Presentation transcript:

Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math and number theory July 15: Coordinate geometry July 22: Graph, BFS, DFS, topological sort July 29: Graph, MST, bipartite matching Aug 5: Individual contest 1 Aug 12: Individual contest 2 Aug 19: Dynamic programming Aug 26: Team Formation Test

What is recursion? 1. Do something 2. Repeat Any algorithm that have the above format is using "recursion". Properties: Easy to design and write Tend to be slow (because trying all possibilities)

What is a greedy algorithm? 1. Make a choice that looks good (greedy choice) 2. Repeat if the problem is not yet solved

Examples. Event scheduling Given a set S of n events, each event i has a starting a_i and ending time b_i, where a_i and b_i are integers. Find a largest subset S’ of events such that for any two events i and j, [a_i, b_i] and [a_j, b_j] are non-overlapping

Examples. Event scheduling Idea 1. Pick the shortest jobs whenever possible Idea 2. First-come-first-serve

Examples. Event scheduling Idea 3. Pick the job that ends first Proof that it is optimal. Let e1, e2, …, er be events picked by our algorithm Greedy. Let e1’, e2’, …, es’ be events picked by the optimal. Note that the ending time of e1 <= ending time of e1’. Therefore, after picking e1, Greedy can choose both e2 and e2’. Greedy picks e2, so ending time of e2 <= ending time e2’. Assume s > r, Greedy should pick more than r jobs. Contradiction.

Properties of greedy algorithms 1. Make a choice that looks good (greedy choice) 2. Repeat if the problem is not yet solved Easy to design and write Tend to be fast (because make only 1 greedy choice) Finding the correct greedy choice and proving the correctness is usually hard.

Examples. Event scheduling 2 Given a set S of n events, each event i has a starting a_i and ending time b_i, where a_i and b_i are integers. Divide S into minimum number of groups G1, G2, … of events such that for any two events i and j in the same group, [a_i, b_i] and [a_j, b_j] are non-overlapping

Examples. Event scheduling 2 Idea 1. First-come-first-serve Proof that it is optimal. Let r be the number of groups we use eventually. Let E be the first events put to the r-th group. Notice that we have found r jobs that are overlapping. Therefore, minimum number of groups >= r. Since we use r groups, we are optimal.

Properties of greedy algorithms 1. Make a choice that looks good (greedy choice) 2. Repeat if the problem is not yet solved Easy to design and write Tend to be fast (because trying all possibilities) Finding the correct greedy choice and proving the correctness is usually hard.

Examples. Event scheduling 3 Given a set S of n events, each event I with a size s_i and a weight w_i. Jobs can be processed starting from time 0. The weighted completion time of an event = (completion time) (w_i). w = w = 23 3w = 1 Find an order that minimize the total weighted completion time.

Examples. Event scheduling 3 Idea 1. Shortest job first w = w = 41 Idea 2 Highest weight first w = w = 21

Examples. Event scheduling 3 Idea 3. Highest density first, where density = weight / size w = w = 41 w = w = 21 Proof that it is optimal. Assume that in the optimal schedule, it processes a job i with smaller density first then an other job j with larger density. Consider the change in total weighted completion time if we process j before i. Simple calculation will show that the total weighted completion time decreases, which leads to a contradiction.

Exercises 120, 410, 714, 10020, 10026, 10672, 10700, 10821, 10954, 10982, 11039, , 10954, 283, 444, 644.