HKOI 2004 Team Training Greedy Algorithms (Intermediate Level)

Slides:



Advertisements
Similar presentations
Dynamic Programming 25-Mar-17.
Advertisements

Design and Analysis of Algorithms Introduction to Divide-and-conquer Haidong Xue Summer 2012, at GSU.
Greedy Algorithms.
Types of Algorithms.
Chapter 5 Fundamental Algorithm Design Techniques.
TIM AU YEUNG HKOI 2012 Greedy. Try some cases Make a guess local optimum -> global optimum Not really a specific algorithm  Practice more  By feelings.
Analysis of Algorithms
Algorithms + L. Grewe.
Dynamic Programming.
For Monday Read 10.3 Homework: –Chapter 10, exercise 10.
Greedy Algorithms Basic idea Connection to dynamic programming Proof Techniques.
Outline 1. General Design and Problem Solving Strategies 2. More about Dynamic Programming – Example: Edit Distance 3. Backtracking (if there is time)
Click to start.
Lecture 7: Greedy Algorithms II Shang-Hua Teng. Greedy algorithms A greedy algorithm always makes the choice that looks best at the moment –My everyday.
CSE 780 Algorithms Advanced Algorithms Greedy algorithm Job-select problem Greedy vs DP.
Greedy Algorithms CIS 606 Spring Greedy Algorithms Similar to dynamic programming. Used for optimization problems. Idea – When we have a choice.
Lecture 34 CSE 331 Nov 30, Graded HW 8 On Wednesday.
KNAPSACK PROBLEM A dynamic approach. Knapsack Problem  Given a sack, able to hold K kg  Given a list of objects  Each has a weight and a value  Try.
Dynamic Programming 0-1 Knapsack These notes are taken from the notes by Dr. Steve Goddard at
1 Algorithm Design Techniques Greedy algorithms Divide and conquer Dynamic programming Randomized algorithms Backtracking.
David Luebke 1 8/23/2015 CS 332: Algorithms Greedy Algorithms.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2008 Dynamic programming  top-down vs. bottom-up  divide & conquer vs. dynamic programming  examples:
1 Summary: Design Methods for Algorithms Andreas Klappenecker.
1 0-1 Knapsack problem Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
David Luebke 1 10/24/2015 CS 332: Algorithms Greedy Algorithms Continued.
CSC 413/513: Intro to Algorithms Greedy Algorithms.
Fraction Easy for you!!
CSC401: Analysis of Algorithms CSC401 – Analysis of Algorithms Chapter Dynamic Programming Objectives: Present the Dynamic Programming paradigm.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
DP (not Daniel Park's dance party). Dynamic programming Can speed up many problems. Basically, it's like magic. :D Overlapping subproblems o Number of.
Gary Sham HKOI 2010 Greedy, Divide and Conquer. Greedy Algorithm Solve the problem by the “BEST” choice. To find the global optimal through local optimal.
6/4/ ITCS 6114 Dynamic programming Longest Common Subsequence.
1 Chapter 15-1 : Dynamic Programming I. 2 Divide-and-conquer strategy allows us to solve a big problem by handling only smaller sub-problems Some problems.
CSC 201: Design and Analysis of Algorithms Greedy Algorithms.
Greedy Algorithms. What is “Greedy Algorithm” Optimization problem usually goes through a sequence of steps A greedy algorithm makes the choice looks.
Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math.
Click to start Fractions 1 2 / 10 1 / 12 1/81/8 1 ½ 11 / / 60.
1 Dynamic Programming Topic 07 Asst. Prof. Dr. Bunyarit Uyyanonvara IT Program, Image and Vision Computing Lab. School of Information and Computer Technology.
PROBLEM-SOLVING TECHNIQUES Rocky K. C. Chang November 10, 2015.
Dynamic Programming.  Decomposes a problem into a series of sub- problems  Builds up correct solutions to larger and larger sub- problems  Examples.
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
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 Chapter 16: Greedy Algorithm. 2 About this lecture Introduce Greedy Algorithm Look at some problems solvable by Greedy Algorithm.
Fundamental Data Structures and Algorithms Ananda Guna March 18, 2003 Dynamic Programming Part 1.
Introductory material Jonathan Godfrey.
Dynamic Programming. What is Dynamic Programming  A method for solving complex problems by breaking them down into simpler sub problems. It is applicable.
Divide and Conquer. Problem Solution 4 Example.
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding.
CSCI 58000, Algorithm Design, Analysis & Implementation Lecture 12 Greedy Algorithms (Chapter 16)
Greedy algorithms: CSC317
CSC317 Greedy algorithms; Two main properties:
Design & Analysis of Algorithm Dynamic Programming
Fractions Click to start Created By Dr. Cary Lee
Lecture 5 Dynamic Programming
0/1 Knapsack Making Change (any coin set)
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Lecture 5 Dynamic Programming
CS 3343: Analysis of Algorithms
Algorithm Design Methods
CS 3343: Analysis of Algorithms
CS Algorithms Dynamic programming 0-1 Knapsack problem 12/5/2018.
Greedy Algorithms Many optimization problems can be solved more quickly using a greedy approach The basic principle is that local optimal decisions may.
Advanced Algorithms Analysis and Design
Fractions 1/8 55/60 11/12 1 2/10 1 ½ 1/12.
Chapter 15-1 : Dynamic Programming I
Longest Common Subsequence
CSC 413/513- Intro to Algorithms
0-1 Knapsack problem.
COMPSCI 330 Design and Analysis of Algorithms
Presentation transcript:

HKOI 2004 Team Training Greedy Algorithms (Intermediate Level)

Overview Is there anything for me to teach?

What is “Greedy Algorithm”? We are greedy, aren ’ t we? Sometimes, we want more e.g. money, exam score,... Sometimes, we want less e.g. shortest distance or time, cost of goods,... With information on our hands, we may choose the best (most or least) things until we ’ ve achieved our goals. Buy things in the cheapest way in a supermarket. More examples later.

What is “Greedy Algorithm”? From another point of view... Sometimes, when the problem... Is so straight forward, That can be cut into sub-problems, Until we reach a trivial base case, Then solve the trivial case, then the not- so-trivial sub-problems, and so on, until we can solve the original big problem, i.e. the famous Divide and Conquer !!! Well... Isn’t it recursion then?

What is an “Greedy Algorithm”? Divide and conquer does NOT mean recursion! Recursion, dynamic programming (DyP), greedy, etc... The approaches are different Recursion: top-down Cut the big problem into smaller ones, then solve them, finally solve the big one

What is an “Greedy Algorithm”? Dynamic programming: bottom-up Solve the small problems first, then build up the solution for larger problems, and larger, and larger, until one day, we “suddenly” discover that we have just solved the big problem! Greedy: it depends... Solve the small problems first, then build up the solution for larger problems, and larger, and larger, until one day, we find no difference between Greedy and DyP?!

Greedy vs. DyP Well, there is no difference. Greedy is DyP. Except that... Greedy is actually a special case of DyP. A Greedy-solvable problem is one that can only be cut into one Greedy-solvable sub- problem. A DyP-solvable problem often involves finding the optimal solution from N DyP- solved sub-problems. See “Introduction to Algorithm” P.9, 10

Greedy vs. D&C So how can you prove that a problem can be solved by D&C? I think someone has taught you already. So how can you proof that a problem can be solved by solving only one sub- problem? Intuitively?!

Greedy vs. D&C Well, I am weak in proving things, and sometimes you don’t have much time to really prove things “formally” in a competition. So, please convince yourself by yourself. For your information, the “Unu’s conjecture of competition” states that: If you have a not-yet-proved “solution” to a problem, but you don’t know its correctness (i.e you can’t prove) and you can’t disprove it either, then it is correct.

Example: Fractional Knapsack Given materials of different values per unit volume and maximum amounts, find the most valuable mix of materials which fit in a knapsack of a fixed volume. Note that we may take pieces (fractions) of materials. Proof: cse2320/lectures/l15/node6.html cse2320/lectures/l15/node6.html

Example: $$$ Why we have these HKD? Notes: $1000, $500, $100, $50, $20, $10 Coins: $10, $5, $2, $1, $0.5, $0.2, $0.1 Because in that way, any amount can be solved by Greedy! All money in the world organize in the same way. At least I’ve seen none that is not... Unfortunately, stamps are not...

Counter-example: UVA10003 – Cutting Sticks Greedy solvable? We need to solve many possible sub- problems first before solving the big problem, and some kind of processing is needed. A DyP problem actually.

(Not-so-)Counter-example: UVA10037 – Bridge Play here! Greedy solvable? Well, not that straight forward. Base case: 1 or 2 or 3 person/people Then consider the 2 fastest and 2 slowest persons if there are still 4 or more people.

Less straight forward example: 2014 – Activities A greedy person has to be clever! Several “obvious” ways to “greedy” out the answer, but may be wrong! By first start time? By shortest duration? By fewest overlap? By first end time? By... Try to solve it yourself!

Exercises (Greedy or not?)