CSC 380: Design and Analysis of Algorithms

Slides:



Advertisements
Similar presentations
Coordination Mechanisms for Unrelated Machine Scheduling Yossi Azar joint work with Kamal Jain Vahab Mirrokni.
Advertisements

Math for Liberal Studies. There is a list of numbers called weights These numbers represent objects that need to be packed into bins with a particular.
Introduction to Algorithms Greedy Algorithms
Algorithm Design Techniques: Greedy Algorithms. Introduction Algorithm Design Techniques –Design of algorithms –Algorithms commonly used to solve problems.
Greedy Algorithms Basic idea Connection to dynamic programming
1 Greedy Algorithms. 2 2 A short list of categories Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
CSE 421 Algorithms Richard Anderson Lecture 6 Greedy Algorithms.
Ecole Polytechnique, Nov 7, Online Job Scheduling Marek Chrobak University of California, Riverside.
ASC Program Example Part 3 of Associative Computing Examining the MST code in ASC Primer.
Algorithms and Economics of Networks: Coordination Mechanisms Abraham Flaxman and Vahab Mirrokni, Microsoft Research.
Lecture 23. Greedy Algorithms
Dr. Naveed Ahmad Assistant Professor Department of Computer Science University of Peshawar.
Image segmentation Prof. Noah Snavely CS1114
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Class Schedule: Class Announcements Homework Questions 3.4 Notes Begin Homework.
Spring 2008The Greedy Method1. Spring 2008The Greedy Method2 Outline and Reading The Greedy Method Technique (§5.1) Fractional Knapsack Problem (§5.1.1)
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.
Great Theoretical Ideas in Computer Science.
CSC 231: Introduction to Data Structures Python and Objects – Day 3 Dr. Curry Guinn.
Greedy Algorithms.
CSC 131: Introduction to Computer Science
Lecture 32 CSE 331 Nov 16, 2016.
Algorithm Design Methods
Greedy Algorithms.
Lecture 8: Dispatch Rules
CSC 131: Introduction to Computer Science
Greedy Algorithms Basic idea Connection to dynamic programming
Cinda Heeren / Geoffrey Tien
CSC 380: Design and Analysis of Algorithms
Types of Algorithms.
Presented by Po-Chuan & Chen-Chen 2016/03/08
Multi - Way Number Partitioning
Objective of This Course
The Greedy Method Spring 2007 The Greedy Method Merge Sort
Advanced Analysis of Algorithms
Lecture 11 Overview Self-Reducibility.
Lecture 11 Overview Self-Reducibility.
Graph Searching.
Richard Anderson Lecture 6 Greedy Algorithms
Lecture 19 CSE 331 Oct 8, 2014.
Lecture 20 CSE 331 Oct 17, 2011.
Lecture 32 CSE 331 Nov 15, 2017.
Richard Anderson Autumn 2016 Lecture 7
Lecture 18 CSE 331 Oct 9, 2017.
Richard Anderson Lecture 7 Greedy Algorithms
CSE 326: Data Structures Lecture #24 The Algorhythmics
CSC 380: Design and Analysis of Algorithms
Greedy Algorithms: Introduction
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Algorithm Design Methods
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Richard Anderson Winter 2019 Lecture 7
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Lecture 19 CSE 331 Oct 10, 2016.
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
CSC 380: Design and Analysis of Algorithms
Algorithm Design Methods
Richard Anderson Autumn 2019 Lecture 7
Presentation transcript:

CSC 380: Design and Analysis of Algorithms Dr. Curry Guinn

Quick Info Dr. Curry Guinn CIS 2015 guinnc@uncw.edu www.uncw.edu/people/guinnc 962-7937 Office Hours: MWF: 10:00am-11:00m and by appointment

Outline of today Fancy sorting Scheduling problems One where a greedy algorithm works And then One a very, very similar problem where the greedy algorithm doesn’t work and, in fact, there is no “good” solution

A Fancy Sorting Algorithm TwoPivotQuicksort with other modifications

Optimization problems An optimization problem is one in which you want to find, not just a solution, but the best solution A “greedy algorithm” sometimes works well for optimization problems A greedy algorithm works in phases. At each phase: You take the best you can get right now, without regard for future consequences You hope that by choosing a local optimum at each step, you will end up at a global optimum 2

Scheduling Given jobs j1, j2, j3, ..., jn with known running times t1, t2, t3, ..., tn – what is the best way to schedule the jobs to minimize average completion time? Job Time j1 15 j2 8 j3 3 j4 10

Optimality Proof Total cost of a schedule is N ∑(N-k+1)tk k=1 t1 + (t1+t2) + (t1+t2+t3) ... (t1+t2+...+tn) N N (N+1)∑tk - ∑k*tk k=1 k=1 First term independent of ordering, as second term increases, total cost becomes smaller

More Scheduling Multiple processor case Algorithm? You have to run nine jobs, with running times of 3, 5, 6, 10, 11, 14, 15, 18, and 20 minutes You have three processors on which you can run these jobs Minimize the average completion time.

A different multi-processor scheduling problem You have to run nine jobs, with running times of 3, 5, 6, 10, 11, 14, 15, 18, and 20 minutes You have three processors on which you can run these jobs You want to minimize the total running time. You decide to do the longest-running jobs first, on whatever processor is available P1 P2 P3 20 10 3 18 11 6 15 14 5 Time to completion: 18 + 11 + 6 = 35 minutes This solution isn’t bad, but we might be able to do better 5

Another approach What would be the result if you ran the shortest job first? Again, the running times are 3, 5, 6, 10, 11, 14, 15, 18, and 20 minutes P1 P2 P3 3 10 15 5 11 18 6 14 20 That wasn’t such a good idea; time to completion is now 6 + 14 + 20 = 40 minutes Note, however, that the greedy algorithm itself is fast All we had to do at each stage was pick the minimum or maximum 6

An optimum solution Better solutions do exist: 20 18 15 14 11 10 6 5 3 This solution is clearly optimal (why?) Clearly, there are other optimal solutions (why?) How do we find such a solution? One way: Try all possible assignments of jobs to processors Unfortunately, this approach can take exponential time 7

Summary of Scheduling Multiple processor case, Minimize Average Completion Time Algorithm: order jobs shortest first schedule jobs round-robin Minimizing final completion time How is this different? Problem is NP-Complete!

For Next Class, Friday Chapter 11: Limitations of Algorithm Power Homework 5 due Thursday