SlideShare a Scribd company logo
Chapter 8

Approximation Algorithms
(Part II)

1
Outline



Scheduling Independent tasks
Bin packing

2
Scheduling independent tasks








An instance of the scheduling problem is defined by a
set of n task times, ti, 1≤ i ≤ n, and m, the number of
processors.
Obtaining minimum finish time schedules is NPcomplete.
The scheduling rule we will use is called the LPT
(longest processing time) rule.
Definition: An LPT schedule is one that is the result of
an algorithm, which, whenever a processor becomes
free, assigns to that processor a task whose time is the
largest of those tasks not yet assigned.

3
Example




Let m = 3, n = 6 and (t1, t2, t3, t4, t5, t6) = (8, 7, 6, 5, 4,
3). In an LPT schedule tasks 1, 2 and 3 respectively.
Tasks 1, 2, and 3 are assigned to processors 1, 2
and 3. Tasks 4, 5 and 6 are respectively assigned to
the processors 3, 2, and 1.
The finish time is 11. Since Σ ti /3 = 11, the schedule
is also optimal.
678

11

P1

1

6

P3

2

5

P3

3

4

4
Example


Let m = 3, n = 6 and (t1, t2, t3, t4, t5, t6, t7) = (5, 5, 4, 4, 3,
3, 3). The LPT schedule is shown in the following
figure. This has a finish time is 11. The optimal
schedule is 9. Hence, for this instance |F*(I) –
F(I)|/F*(I) = (11-9)/9=2/9.

4 5
P1

1

8
5

11
7

9
1

3
4

P2

2

6

2

P3

3

4

5

(a) LPT schedule

6

7

(b) Optimal schedule
5


While the LPT rule may generate optimal schedules for
some problem instances, it does not do so for all
instances. How bad can LPT schedules be relative to
optimal schedules?



Theorem: [Graham] Let F*(I) be the finish time of an
optimal m processor schedule for instance I of the task
scheduling problem. Let F(I) be the finish time of an LPT
schedule for the same instance, then
|F*(I)-F(I)|/F*(I) ≤ 1/3 – 1/(3m)

The proof of this theorem can be referred to the book
“Fundamentals of Computer Algorithms”, E. Horowitz and
S. Sahni, Pitman Publishing, 1978.

6
Bin Packing









We are given n objects which have to be placed in
bins of equal capacity L.
Object i requires li units of bin capacity.
The objective is to determine the minimum number
of bins needed to accommodate all n objects.
Example: Let L = 10, n = 6 and (l1, l2, l3, l4, l5, l6) = (5, 6,
3, 7, 5,4)
The bin packing problem is NP-complete.

7
Four heuristics






One can derive many simple heuristics for the bin
packing problem. In general, they will not obtain
optimal packings.
However, they obtain packings that use only a
“small” fraction of bins more than an optimal
packing.
Four heuristics:





First fit (FF)
Best fit (BF)
First fit Decreasing (FFD)
Best fit Decreasing (BFD)

8
First-fit and Best-fit


First-fit




Index the bins 1, 2, 3,… All bins are initially filled to level 0.
Objects are considered for packing in the order 1, 2, …, n.
To pack object i, find the least index j such that bin j is filled
to the level r (r ≤ L – li). Pack I into bin j. Bin j is now filled to
level r + li.

Best-fit


The initial conditions are the same as for FF. When object i
is being considered, find the least j such that bin j is filled to
a level r (r ≤ L – li) and r is as large as possible. Pack i into
bin j. Bin j is now filled to level r + li.

9
Example
6

(a) First Fit

3
1

5

1

2

4
5

(b) Best Fit

3
4
2

6

10
First-fit decreasing and Best-fit decreasing


First-fit decreasing (FFD)




Reorder the objects so that li ≥ li+1, 1 ≤ i ≤ n. Now
use First-fit to pack the objects.

Best-fit decreasing (BFD)


Reorder the objects so that li ≥ li+1, 1 ≤ i ≤ n. Now
use First-fit to pack the objects.

11
Example
3

6

4

2

5

1

(c) First Fit Decreasing and Best Fit Decreasing

FFD and BFD do better than either FF or BF on this
instance. While FFD and BFD obtain optimal packings on
this example, they do not in general obtain such a
packings.
12
Theorem


Let I be an instance of the bin packing problem and let
F*(I) be the minimum number of bins needed for this
instance. The packing generated by either FF or BF uses
no more than (17/10)F*(I)+2 bins. The packings
generated by either FFD or BFD uses no more than
(11/9)F*(I)+4 bins.



This proof of this theorem is long and complex (given by
Johnson et al., 1974).

13
Appendix: A Taxonomy of Algorithm
Design Strategies
Strategy name
Examples
---------------------------------------------------------------------------------------Bruce-force
Sequential search, selection sort
Divide-and-conquer
Quicksort, mergesort, binary search
Decrease-and-conquer
Insertion sort, DFS, BFS
Transform-and-conquer
heapsort, Gauss elimination
Greedy
Prim’s, Dijkstra’s
Dynamic Programming
Floyd’s
Backtracking
Branch-and-Bound
Approximate algorithms
Heuristics
Meta-heuristics
14

More Related Content

DOCX
تصنيف المصادر حسب المعايير1
PDF
Modular representation theory of finite groups
PDF
An25237245
PPT
A small debate of power of randomness
PPTX
Asymptotic analysis
PDF
PDF
Minimum Size of Generating Set for Transitive p - Group G of Degree 3 p .
PPT
Bag of Timestamps: A Simple and Efficient Bayesian Chronological Mining
تصنيف المصادر حسب المعايير1
Modular representation theory of finite groups
An25237245
A small debate of power of randomness
Asymptotic analysis
Minimum Size of Generating Set for Transitive p - Group G of Degree 3 p .
Bag of Timestamps: A Simple and Efficient Bayesian Chronological Mining

What's hot (17)

DOC
Model toc
PPTX
String matching algorithms-pattern matching.
PDF
Cs6503 theory of computation may june 2016 be cse anna university question paper
DOCX
Cs6503 theory of computation november december 2016
PDF
PDF
Cs6503 theory of computation november december 2015 be cse anna university q...
PDF
DOCX
Cs6503 theory of computation april may 2017
PPTX
Daa unit 5
PDF
A Concurrent Language for Argumentation
PDF
Timed Concurrent Language for Argumentation: an Interleaving Approach
PPTX
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
PPTX
Enhancing user experiences with reactive extensions tccc10
PPTX
Tsp is NP-Complete
PDF
32 -longest-common-prefix
PDF
Generazione Automatica di Test - S. Vuotto (Università di Sassari)
PDF
Answer True/False and explain for each part. (Short Answer) 1. Say that w...
Model toc
String matching algorithms-pattern matching.
Cs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation november december 2016
Cs6503 theory of computation november december 2015 be cse anna university q...
Cs6503 theory of computation april may 2017
Daa unit 5
A Concurrent Language for Argumentation
Timed Concurrent Language for Argumentation: an Interleaving Approach
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Enhancing user experiences with reactive extensions tccc10
Tsp is NP-Complete
32 -longest-common-prefix
Generazione Automatica di Test - S. Vuotto (Università di Sassari)
Answer True/False and explain for each part. (Short Answer) 1. Say that w...
Ad

Similar to Chap8 part ii (20)

PPTX
THE GREEDY METHOD notes related to education.pptx
PDF
04greedy 2x2
PDF
Bin packing problem two approximation
PDF
BIN PACKING PROBLEM: TWO APPROXIMATION ALGORITHMS
PPTX
Algorithm Design Techiques, divide and conquer
PDF
7f44bdd880a385b7c1338293ea4183f930ea
PPTX
data structures and algorithms Unit 4
PDF
BinPacking.pdf Dfghhjkkjjjjmkkkjnjjjjmmmk
PDF
Design And Analysis Of Algorithms Lecture Notes Mit 6046j Itebooks
PDF
Exam100412
PDF
Time Complexity Analysis 1st Edition Aditya Chatterjee
PPT
12-greedy.ppt
PPT
2010 3-24 cryptography stamatiou
PPTX
Ch-2 final exam documet compler design elements
PPTX
algorithm assignmenteeeeeee.pptx
PPT
Knapsack prooblem using greedy based algoithm
PPT
Elak1 greedy presentation for design and analysis of algorithms.ppt
PDF
An Exact Exponential Branch-And-Merge Algorithm For The Single Machine Total ...
PPTX
RProgrammingassignmenthPPT_05.07.24.pptx
THE GREEDY METHOD notes related to education.pptx
04greedy 2x2
Bin packing problem two approximation
BIN PACKING PROBLEM: TWO APPROXIMATION ALGORITHMS
Algorithm Design Techiques, divide and conquer
7f44bdd880a385b7c1338293ea4183f930ea
data structures and algorithms Unit 4
BinPacking.pdf Dfghhjkkjjjjmkkkjnjjjjmmmk
Design And Analysis Of Algorithms Lecture Notes Mit 6046j Itebooks
Exam100412
Time Complexity Analysis 1st Edition Aditya Chatterjee
12-greedy.ppt
2010 3-24 cryptography stamatiou
Ch-2 final exam documet compler design elements
algorithm assignmenteeeeeee.pptx
Knapsack prooblem using greedy based algoithm
Elak1 greedy presentation for design and analysis of algorithms.ppt
An Exact Exponential Branch-And-Merge Algorithm For The Single Machine Total ...
RProgrammingassignmenthPPT_05.07.24.pptx
Ad

More from Loc Tran (13)

DOCX
đạI học quốc gia thành phố hồ chí minh
PPT
Chap8 new
PPT
Chap7 new
PPT
Chap6 new
PPT
Chap5 new
PPT
Chap4 new
PPT
Chap4 new (tran dai's conflicted copy 2013 04-02)
PPT
Chap3 new
PPT
Chap2 new
PPT
Chap2 new (tran dai's conflicted copy 2013 04-02)
PPT
Chap1 new (tran dai's conflicted copy 2013 04-02)
PPT
Appendix b 2
PPT
Appendix a 2
đạI học quốc gia thành phố hồ chí minh
Chap8 new
Chap7 new
Chap6 new
Chap5 new
Chap4 new
Chap4 new (tran dai's conflicted copy 2013 04-02)
Chap3 new
Chap2 new
Chap2 new (tran dai's conflicted copy 2013 04-02)
Chap1 new (tran dai's conflicted copy 2013 04-02)
Appendix b 2
Appendix a 2

Recently uploaded (20)

PDF
Computing-Curriculum for Schools in Ghana
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Pharma ospi slides which help in ospi learning
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Complications of Minimal Access Surgery at WLH
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Types and Its function , kingdom of life
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Institutional Correction lecture only . . .
Computing-Curriculum for Schools in Ghana
PPH.pptx obstetrics and gynecology in nursing
Pharma ospi slides which help in ospi learning
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Complications of Minimal Access Surgery at WLH
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
RMMM.pdf make it easy to upload and study
Cell Types and Its function , kingdom of life
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
GDM (1) (1).pptx small presentation for students
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
Insiders guide to clinical Medicine.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Institutional Correction lecture only . . .

Chap8 part ii

  • 3. Scheduling independent tasks     An instance of the scheduling problem is defined by a set of n task times, ti, 1≤ i ≤ n, and m, the number of processors. Obtaining minimum finish time schedules is NPcomplete. The scheduling rule we will use is called the LPT (longest processing time) rule. Definition: An LPT schedule is one that is the result of an algorithm, which, whenever a processor becomes free, assigns to that processor a task whose time is the largest of those tasks not yet assigned. 3
  • 4. Example   Let m = 3, n = 6 and (t1, t2, t3, t4, t5, t6) = (8, 7, 6, 5, 4, 3). In an LPT schedule tasks 1, 2 and 3 respectively. Tasks 1, 2, and 3 are assigned to processors 1, 2 and 3. Tasks 4, 5 and 6 are respectively assigned to the processors 3, 2, and 1. The finish time is 11. Since Σ ti /3 = 11, the schedule is also optimal. 678 11 P1 1 6 P3 2 5 P3 3 4 4
  • 5. Example  Let m = 3, n = 6 and (t1, t2, t3, t4, t5, t6, t7) = (5, 5, 4, 4, 3, 3, 3). The LPT schedule is shown in the following figure. This has a finish time is 11. The optimal schedule is 9. Hence, for this instance |F*(I) – F(I)|/F*(I) = (11-9)/9=2/9. 4 5 P1 1 8 5 11 7 9 1 3 4 P2 2 6 2 P3 3 4 5 (a) LPT schedule 6 7 (b) Optimal schedule 5
  • 6.  While the LPT rule may generate optimal schedules for some problem instances, it does not do so for all instances. How bad can LPT schedules be relative to optimal schedules?  Theorem: [Graham] Let F*(I) be the finish time of an optimal m processor schedule for instance I of the task scheduling problem. Let F(I) be the finish time of an LPT schedule for the same instance, then |F*(I)-F(I)|/F*(I) ≤ 1/3 – 1/(3m) The proof of this theorem can be referred to the book “Fundamentals of Computer Algorithms”, E. Horowitz and S. Sahni, Pitman Publishing, 1978. 6
  • 7. Bin Packing      We are given n objects which have to be placed in bins of equal capacity L. Object i requires li units of bin capacity. The objective is to determine the minimum number of bins needed to accommodate all n objects. Example: Let L = 10, n = 6 and (l1, l2, l3, l4, l5, l6) = (5, 6, 3, 7, 5,4) The bin packing problem is NP-complete. 7
  • 8. Four heuristics    One can derive many simple heuristics for the bin packing problem. In general, they will not obtain optimal packings. However, they obtain packings that use only a “small” fraction of bins more than an optimal packing. Four heuristics:     First fit (FF) Best fit (BF) First fit Decreasing (FFD) Best fit Decreasing (BFD) 8
  • 9. First-fit and Best-fit  First-fit   Index the bins 1, 2, 3,… All bins are initially filled to level 0. Objects are considered for packing in the order 1, 2, …, n. To pack object i, find the least index j such that bin j is filled to the level r (r ≤ L – li). Pack I into bin j. Bin j is now filled to level r + li. Best-fit  The initial conditions are the same as for FF. When object i is being considered, find the least j such that bin j is filled to a level r (r ≤ L – li) and r is as large as possible. Pack i into bin j. Bin j is now filled to level r + li. 9
  • 11. First-fit decreasing and Best-fit decreasing  First-fit decreasing (FFD)   Reorder the objects so that li ≥ li+1, 1 ≤ i ≤ n. Now use First-fit to pack the objects. Best-fit decreasing (BFD)  Reorder the objects so that li ≥ li+1, 1 ≤ i ≤ n. Now use First-fit to pack the objects. 11
  • 12. Example 3 6 4 2 5 1 (c) First Fit Decreasing and Best Fit Decreasing FFD and BFD do better than either FF or BF on this instance. While FFD and BFD obtain optimal packings on this example, they do not in general obtain such a packings. 12
  • 13. Theorem  Let I be an instance of the bin packing problem and let F*(I) be the minimum number of bins needed for this instance. The packing generated by either FF or BF uses no more than (17/10)F*(I)+2 bins. The packings generated by either FFD or BFD uses no more than (11/9)F*(I)+4 bins.  This proof of this theorem is long and complex (given by Johnson et al., 1974). 13
  • 14. Appendix: A Taxonomy of Algorithm Design Strategies Strategy name Examples ---------------------------------------------------------------------------------------Bruce-force Sequential search, selection sort Divide-and-conquer Quicksort, mergesort, binary search Decrease-and-conquer Insertion sort, DFS, BFS Transform-and-conquer heapsort, Gauss elimination Greedy Prim’s, Dijkstra’s Dynamic Programming Floyd’s Backtracking Branch-and-Bound Approximate algorithms Heuristics Meta-heuristics 14