CS223 Advanced Data Structures and Algorithms 1 Greedy Algorithms Neil Tang 4/8/2010.

Slides:



Advertisements
Similar presentations
1D Bin Packing (or “CP? Who cares?”)
Advertisements

Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Algorithm Design Methods Spring 2007 CSE, POSTECH.
Bin Packing First fit decreasing algorithm
 Review: The Greedy Method
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
Greed is good. (Some of the time)
Greedy Algorithms Be greedy! always make the choice that looks best at the moment. Local optimization. Not always yielding a globally optimal solution.
For Monday Read 10.3 Homework: –Chapter 10, exercise 10.
CS541 Advanced Networking 1 Wireless Mesh Networks Neil Tang 1/26/2009.
Beneficial Caching in Mobile Ad Hoc Networks Bin Tang, Samir Das, Himanshu Gupta Computer Science Department Stony Brook University.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
CS541 Advanced Networking 1 Spectrum Sharing in Cognitive Radio Networks Neil Tang 3/23/2009.
CS541 Advanced Networking 1 Dynamic Channel Assignment and Routing in Multi-Radio Wireless Mesh Networks Neil Tang 3/10/2009.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
CS541 Advanced Networking 1 Routing and Shortest Path Algorithms Neil Tang 2/18/2009.
Interference-Aware QoS OLSR for Mobile Ad-hoc Network Routing SAWN 2005, May 24 P. Minet & D-Q. Nguyen.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CS541 Advanced Networking 1 Static Channel Assignment and Routing in Multi-Radio Wireless Mesh Networks Neil Tang 3/9/2009.
CS541 Advanced Networking 1 A Real-Time Communication Architecture for Wireless Sensor Networks Neil Tang 4/22/2009.
Dave Risch. Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Profile-Based Topology Control and Routing of Bandwidth-Guaranteed Flows in Wireless Optical Backbone Networks A. Kashyap, M.K. Khandani, K. Lee, M. Shayman.
Optimal Scheduling of File Transfers with Divisible Sizes on Multiple Disjoint Paths Mugurel Ionut Andreica Polytechnic University of Bucharest Computer.
For Wednesday No reading No homework There will be homework for Friday, as well the program being due – plan ahead.
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
1 Algorithms & Data Structures for Games Lecture 2A Minor Games Programming.
Minimum Spanning Trees CS 146 Prof. Sin-Min Lee Regina Wang.
CS223 Advanced Data Structures and Algorithms 1 Maximum Flow Neil Tang 3/30/2010.
Algorithm Design Methods 황승원 Fall 2011 CSE, POSTECH.
1 Windows Scheduling as a Restricted Version of Bin-packing. Amotz Bar-Noy Brooklyn College Richard Ladner Tami Tamir University of Washington.
Decision Maths 1 Shortest path algorithm Dijkstra’s Algorithm A V Ali :
Math for Liberal Studies.  The knapsack problem is a variation of the bin packing problems we have been discussing  This time, there is just one bin.
Critical Paths and Scheduling Tasks Circuits, Paths, and Schedules.
1 Minimum Interference Algorithm for Integrated Topology Control and Routing in Wireless Optical Backbone Networks Fangting Sun Mark Shayman University.
1 Ch18. The Greedy Methods. 2 BIRD’S-EYE VIEW Enter the world of algorithm-design methods In the remainder of this book, we study the methods for the.
Red-Black Tree Neil Tang 02/07/2008
Bin Packing First fit decreasing algorithm
Algorithm Design Methods
Binary Search Tree Neil Tang 01/28/2010
Bin Packing Optimization
Unweighted Shortest Path Neil Tang 3/11/2010
Design and Analysis of Computer Algorithm (CS575-01)
CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms
Greedy Method     Greedy Matching     Coin Changing     Minimum Spanning Tree     Fractional Knapsack     Dijkstra's Single-Source Shortest-Path.
Minimum Spanning Tree Neil Tang 3/25/2010
Topological Sort Neil Tang 03/02/2010
Exam 2 LZW not on syllabus. 73% / 75%.
Bin Packing First fit decreasing algorithm
Bin packing – First fit algorithm
Heapsort and d-Heap Neil Tang 02/11/2010
Dijkstra’s Shortest Path Algorithm Neil Tang 03/25/2008
Greedy Algorithms / Caching Problem Yin Tat Lee
Bin Packing First fit decreasing algorithm
Binary Search Tree Neil Tang 01/31/2008
Minimum Spanning Tree Neil Tang 4/3/2008
Bin Packing First fit decreasing algorithm
Dynamic Programming 1 Neil Tang 4/15/2008
Algorithm Design Methods
CS223 Advanced Data Structures and Algorithms
Algorithm Design Methods
Dijkstra’s Shortest Path Algorithm Neil Tang 3/2/2010
Maximum Flow Neil Tang 4/8/2008
Prim’s Minimum Spanning Tree Algorithm Neil Tang 4/1/2008
Heapsort and d-Heap Neil Tang 02/14/2008
Bin Packing Michael T. Goodrich Some slides adapted from slides from
Review for Final Neil Tang 05/01/2008
Algorithm Design Methods
Presentation transcript:

CS223 Advanced Data Structures and Algorithms 1 Greedy Algorithms Neil Tang 4/8/2010

CS223 Advanced Data Structures and Algorithms 2 Class Overview  Basic idea  Examples: “Greed is good”  The bin packing problem and the algorithms  The path scheduling problem and the algorithms: Greed is no good.

CS223 Advanced Data Structures and Algorithms 3 Basic Idea  In each phase, it makes the best choice based on the current partial solution and the performance metric.  No future consequences are considered when making decisions.  Usually it will not go back to change the previous choices.

CS223 Advanced Data Structures and Algorithms 4 Examples: “Greed is good”  Dijkstra’s algorithm  Prim’s algorithm  Kruskal’s algorithm

CS223 Advanced Data Structures and Algorithms 5 Bin Packing  Bin packing: Given N items with sizes s 1, s 2,…, s N, where 0  s i  1. The bin packing is to pack these items in the fewest bins, given that each bin has unit capacity.  Online bin packing (dynamic case): Each item must be placed in a bin before the size of the next item is given.  Offline bin packing (static case): You cannot make decision until all the input has been read.

CS223 Advanced Data Structures and Algorithms 6 An Example  Pack: 0.2,0.5,0.4,0.7,0.1,0.3,0.8

CS223 Advanced Data Structures and Algorithms 7 The Next Fit Algorithm  For each new item, check to see if it fits in the same bin as the last one. If it does, place it there. Otherwise, create a new bin.  Time complexity: O(N).

CS223 Advanced Data Structures and Algorithms 8 The Next Fit Algorithm  Pack: 0.2,0.5,0.4,0.7,0.1,0.3,0.8

CS223 Advanced Data Structures and Algorithms 9 The Next Fit Algorithm  Theorem: Let M be the optimal solution. The next fit algorithm never uses more than 2M bins. There exist sequences such that it uses 2M-2 bins.

CS223 Advanced Data Structures and Algorithms 10 The First Fit Algorithm  For each new item, scan the existing bins in order and place it in the first bin that can hold it. Create a new bin if none of them can hold it.  Time complexity: O(N 2 )

CS223 Advanced Data Structures and Algorithms 11 The First Fit Algorithm  Pack: 0.2,0.5,0.4,0.7,0.1,0.3,0.8

CS223 Advanced Data Structures and Algorithms 12 The First Fit Algorithm  Theorem: Let M be the optimal solution. The first fit algorithm never uses more than  1.7M  bins. There exist sequences such that it uses  1.7(M-1)  bins.

CS223 Advanced Data Structures and Algorithms 13 The Best Fit Algorithm  For each new item, scan the existing bins in order and place it in the tightest spot among all bins. Create a new bin if none of them can hold it.  Time complexity: O(N 2 )

CS223 Advanced Data Structures and Algorithms 14 The Best Fit Algorithm  Pack: 0.2,0.5,0.4,0.7,0.1,0.3,0.8

CS223 Advanced Data Structures and Algorithms 15 The Offline Algorithms  The first/best fit decreasing algorithm: Sort the items in the descending order of their sizes, then use the first/best fit algorithm.  Time complexity: O(N 2 )

CS223 Advanced Data Structures and Algorithms 16 The Offline Algorithms  First fit for 0.8, 0.7, 0.5, 0.4, 0.3, 0.2, 0.1

CS223 Advanced Data Structures and Algorithms 17 The Offline Algorithms  Theorem: Let M be the optimal solution. The first fit descending algorithm never uses more than  11/9M+4  bins. There exists sequences such that it uses  11/9M  bins.

CS440 Computer Networks 18 The Path Scheduling Problem Given a path, and free timeslots of every nodes in the path, find a collision-free transmission schedule. J. Tang, G. Xue and C. Chandler, Interference-aware routing and bandwidth allocation for QoS provisioning in multihop wireless networks, Wireless Communications and Mobile Computing (WCMC), Vol. 5, No. 8, 2005, pp

CS440 Computer Networks 19 The First Fit Algorithm

CS440 Computer Networks 20 The Optimal Algorithm