SlideShare a Scribd company logo
1 of 22
Chapter 8

Approximation Algorithms

1
Outline





Why approximation algorithms?
The vertex cover problem
The set cover problem
TSP

2
Why Approximation Algorithms ?







Many problems of practical significance are NPcomplete but are too important to abandon merely
because obtaining an optimal solution is intractable.
If a problem is NP-complete, we are unlikely to find
a polynomial time algorithm for solving it exactly, but
it may still be possible to find near-optimal solution
in polynomial time.
In practice, near-optimality is often good enough.
An algorithm that returns near-optimal solutions is
called an approximation algorithm.

3
Performance bounds for approximation
algorithms






i is an optimization problem instance
c(i) be the cost of solution produced by approximate
algorithm and c*(i) be the cost of optimal solution.
For minimization problem, we want c(i)/c*(i) to be as
small as possible.
For maximization problem, we want c*(i)/c(i) to be as
small as possible.
An approximation algorithm for the given problem
instance i, has a ratio bound of p(n) if for any input of
size n, the cost c of the solution produced by the
approximation algorithm is within a factor of p(n) of the
cost c* of an optimal solution. That is
max(c(i)/c*(i), c*(i)/c(i)) ≤ p(n)

4






Note that p(n) is always greater than or equal to 1.
If p(n) = 1 then the approximate algorithm is an
optimal algorithm.
The larger p(n), the worst algorithm
Relative error




We define the relative error of the approximate algorithm
for any input size as
|c(i) - c*(i)|/ c*(i)
We say that an approximate algorithm has a relative error
bound of ε(n) if
|c(i)-c*(i)|/c*(i)≤ ε(n)

5
1. The Vertex-Cover Problem







Vertex cover: given an undirected graph G=(V,E),
then a subset V'⊆V such that if (u,v)∈E, then u∈V'
or v ∈V' (or both).
Size of a vertex cover: the number of vertices in it.
Vertex-cover problem: find a vertex-cover of minimal
size.
This problem is NP-hard, since the related decision
problem is NP-complete

6
Approximate vertex-cover algorithm

The running time of this algorithm is O(E).

7
8
Theorem:




APPROXIMATE-VERTEX-COVER has a ratio
bound of 2, i.e., the size of returned vertex cover
set is at most twice of the size of optimal vertexcover.
Proof:




It runs in poly time
The returned C is a vertex-cover.
Let A be the set of edges picked in line 4 and C*
be the optimal vertex-cover.




Then C* must include at least one end of each edge in A
and no two edges in A are covered by the same vertex
in C*, so |C*|≥|A|.
Moreover, |C|=2|A|, so |C|≤2|C*|.
9
The Set Covering Problem




The set covering problem is an optimization problem that models
many resource-selection problems.
An instance (X, F) of the set-covering problem consists of a
finite set X and a family F of subsets of X, such that every
element of X belongs to at least one subset in F:

X =∪S
S∈F


We say that a subset S∈F covers its elements.
The problem is to find a minimum-size subset C ⊆ F whose
members cover all of X:

X =∪S
S∈C


We say that any C satisfying the above equation covers X.

10
Figure 6.2 An instance {X, F} of the set covering problem, where X
consists of the 12 black points and F = { S1, S2, S3, S4, S5, S6}. A
minimum size set cover is C = { S3, S4, S5}. The greedy algorithm
produces the set C’ = {S1, S4, S5, S3} in order.
11
Applications of Set-covering problem






Assume that X is a set of skills that are needed to
solve a problem and we have a set of people
available to work on it. We wish to form a team,
containing as few people as possible, s.t. for every
requisite skill in X, there is a member in the team
having that skill.
Assign emergency stations (fire stations) in a city.
Allocate sale branch offices for a company.
Schedule for bus drivers.

12
A greedy approximation algorithm
Greedy-Set-Cover(X, F)
1. U = X
2. C = ∅
3. while U != ∅ do
4.
select an S∈F that maximizes | S ∩ U|
5.
U=U–S
6.
C = C ∪ {S}
7. return C
The algorithm GREEDY-SET-COVER can easily be
implemented to run in time complexity in |X| and |F|. Since the
number of iterations of the loop on line 3-6 is at most min(|X|, |
F|) and the loop body can be implemented to run in time O(|
X|,|F|), there is an implementation that runs in time O(|X|,|F|
min(|X|,|F|) .

13
Ratio bound of Greedy-set-cover


Let denote the dth harmonic number
d

hd = Σi-11/i




Theorem: Greedy-set-cover has a ratio bound
H(max{|S|: S ∈F})
Corollary: Greedy-set-cover has a ratio bound of (ln|
X| +1)
(Refer to the text book for the proofs)

14
3. The Traveling Salesman Problem


Since finding the shortest tour for TSP requires so
much computation, we may consider to find a tour
that is almost as short as the shortest. That is, it
may be possible to find near-optimal solution.



Example: We can use an approximation algorithm
for the HCP. It's relatively easy to find a tour that is
longer by at most a factor of two than the optimal
tour. The method is based on



the algorithm for finding the minimum spanning tree and
an observation that it is always cheapest to go directly from
a vertex u to a vertex w; going by way of any intermediate
stop v can’t be less expensive.
C(u,w) ≤ C(u,v)+ C(v,w)
15
APPROX-TSP-TOUR

The algorithm computes a near-optimal tour of an
undirected graph G.
procedure APPROX-TSP-TOUR(G, c);
begin
select a vertex r ∈ V[G] to be the “root” vertex;
grow a minimum spanning tree T for G from root r, using
Prim’s algorithm;
apply a preorder tree walk of T and let L be the list of
vertices visited in the walk;
form the halmintonian cycle H that visits the vertices in
the order of L.
/* H is the result to return * /
end
A preorder tree walk recursively visits every vertex in the
tree, listing a vertex when its first encountered, before
any of its children are visited.


16
Thí dụ minh họa giải thuật APPROX-TSP-TOUR

17
The preorder tree walk is not simple tour, since a node be visited many
times, but it can be fixed, the tree walk visits the vertices in the order a,
b, c, b, h, b, a, d, e, f, e, g, e, d, a. From this order, we can arrive to the
hamiltonian cycle H: a, b, c, h, d, e ,f, g, a.

18
The optimal tour

The total cost of H is
approximately 19.074. An
optimal tour H* has the total
cost of approximately 14.715.

The running time of APPROX-TSP-TOUR is O(E) = O(V2),
since the input graph is a complete graph.
19
Ratio bound of APPROX-TSP-TOUR


Theorem: APPROX-TSP-TOUR is an approximation algorithm with a ratio bound of 2 for the TSP
with triangle inequality.



Proof: Let H* be an optimal tour for a given set of
vertices. Since we obtain a spanning tree by deleting
any edge from a tour, if T is a minimum spanning tree
for the given set of vertices, then
c(T) ≤ c(H*)
(1)
A full walk of T traverses every edge of T twice, we
have:
c(W) = 2c(T)
(2)
(1) and (2) imply that:
c(W) ≤ 2c(H*)
(3)



20
But W is not a tour, since it visits some vertices more
than once. By the triangle inequality, we can delete a
visit to any vertex from W. By repeatedly applying this
operation, we can remove from W all but the first visit to
each vertex.
 Let H be the cycle corresponding to this preorder walk. It
is a hamiltonian cycle, since every vertex is visited
exactly once. Since H is obtained by deleting vertices
from W, we have
c(H) ≤ c(W)
(4)
 From (3) and (4), we conclude:
c(H) ≤ 2c(H*)
So, APPROX-TSP-TOUR returns a tour whose cost is not
more than twice the cost of an optimal tour.


21
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
22

More Related Content

What's hot

01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithmtaimurkhan803
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programingrupali_2bonde
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programmingTafhim Islam
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Hasanain Alshadoodee
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAsst.prof M.Gokilavani
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptAntaraBhattacharya12
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cutMayank Garg
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman ProblemDaniel Raditya
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmHema Kashyap
 
Turing Machine
Turing MachineTuring Machine
Turing MachineRajendran
 

What's hot (20)

01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Daa:Dynamic Programing
Daa:Dynamic ProgramingDaa:Dynamic Programing
Daa:Dynamic Programing
 
Elements of dynamic programming
Elements of dynamic programmingElements of dynamic programming
Elements of dynamic programming
 
Lower bound
Lower boundLower bound
Lower bound
 
Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking Sum of subsets problem by backtracking 
Sum of subsets problem by backtracking 
 
Lecture26
Lecture26Lecture26
Lecture26
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
implementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity pptimplementation of travelling salesman problem with complexity ppt
implementation of travelling salesman problem with complexity ppt
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Travelling Salesman Problem
Travelling Salesman ProblemTravelling Salesman Problem
Travelling Salesman Problem
 
Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
 
Lecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithmLecture 14 Heuristic Search-A star algorithm
Lecture 14 Heuristic Search-A star algorithm
 
Greedy Algorithms
Greedy AlgorithmsGreedy Algorithms
Greedy Algorithms
 
AI 5 | Local Search
AI 5 | Local SearchAI 5 | Local Search
AI 5 | Local Search
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 

Similar to Chap8 new

Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Nguyễn Công Hoàng
 
Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem sumit gyawali
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpProgramming Homework Help
 
Design and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam HelpDesign and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam HelpProgramming Exam Help
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2MuradAmn
 
Seminar Report (Final)
Seminar Report (Final)Seminar Report (Final)
Seminar Report (Final)Aruneel Das
 
Unit 3 greedy method
Unit 3  greedy methodUnit 3  greedy method
Unit 3 greedy methodMaryJacob24
 
Unit 3 - Greedy Method
Unit 3  - Greedy MethodUnit 3  - Greedy Method
Unit 3 - Greedy MethodMaryJacob24
 
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920Karl Rudeen
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning treeAhmedMalik74
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programminghodcsencet
 
CS 286P Final ProjectCapacitated Vehicle RoutingMetahe
CS 286P Final ProjectCapacitated Vehicle RoutingMetaheCS 286P Final ProjectCapacitated Vehicle RoutingMetahe
CS 286P Final ProjectCapacitated Vehicle RoutingMetaheMargenePurnell14
 

Similar to Chap8 new (20)

Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
 
Daa chapter11
Daa chapter11Daa chapter11
Daa chapter11
 
Analysis of Algorithm
Analysis of AlgorithmAnalysis of Algorithm
Analysis of Algorithm
 
Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Design and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam HelpDesign and Analysis of Algorithms Exam Help
Design and Analysis of Algorithms Exam Help
 
Approx
ApproxApprox
Approx
 
Approximation
ApproximationApproximation
Approximation
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2
 
NP-Completeness - II
NP-Completeness - IINP-Completeness - II
NP-Completeness - II
 
Seminar Report (Final)
Seminar Report (Final)Seminar Report (Final)
Seminar Report (Final)
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
Unit 3 greedy method
Unit 3  greedy methodUnit 3  greedy method
Unit 3 greedy method
 
Unit 3 - Greedy Method
Unit 3  - Greedy MethodUnit 3  - Greedy Method
Unit 3 - Greedy Method
 
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920
fb69b412-97cb-4e8d-8a28-574c09557d35-160618025920
 
Project Paper
Project PaperProject Paper
Project Paper
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Absorbing Random Walk Centrality
Absorbing Random Walk CentralityAbsorbing Random Walk Centrality
Absorbing Random Walk Centrality
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
CS 286P Final ProjectCapacitated Vehicle RoutingMetahe
CS 286P Final ProjectCapacitated Vehicle RoutingMetaheCS 286P Final ProjectCapacitated Vehicle RoutingMetahe
CS 286P Final ProjectCapacitated Vehicle RoutingMetahe
 

More from Loc Tran

đạI học quốc gia thành phố hồ chí minh
đạI học quốc gia thành phố hồ chí minhđạI học quốc gia thành phố hồ chí minh
đạI học quốc gia thành phố hồ chí minhLoc Tran
 
Chap4 new (tran dai's conflicted copy 2013 04-02)
Chap4 new (tran dai's conflicted copy 2013 04-02)Chap4 new (tran dai's conflicted copy 2013 04-02)
Chap4 new (tran dai's conflicted copy 2013 04-02)Loc Tran
 
Chap2 new (tran dai's conflicted copy 2013 04-02)
Chap2 new (tran dai's conflicted copy 2013 04-02)Chap2 new (tran dai's conflicted copy 2013 04-02)
Chap2 new (tran dai's conflicted copy 2013 04-02)Loc Tran
 
Chap1 new (tran dai's conflicted copy 2013 04-02)
Chap1 new (tran dai's conflicted copy 2013 04-02)Chap1 new (tran dai's conflicted copy 2013 04-02)
Chap1 new (tran dai's conflicted copy 2013 04-02)Loc Tran
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2Loc Tran
 
Appendix a 2
Appendix a 2Appendix a 2
Appendix a 2Loc Tran
 
Chap8 part ii
Chap8 part iiChap8 part ii
Chap8 part iiLoc Tran
 

More from Loc Tran (13)

đạI học quốc gia thành phố hồ chí minh
đạI học quốc gia thành phố hồ chí minhđạI học quốc gia thành phố hồ chí minh
đạI học quốc gia thành phố hồ chí minh
 
Chap7 new
Chap7 newChap7 new
Chap7 new
 
Chap6 new
Chap6 newChap6 new
Chap6 new
 
Chap5 new
Chap5 newChap5 new
Chap5 new
 
Chap4 new
Chap4 newChap4 new
Chap4 new
 
Chap4 new (tran dai's conflicted copy 2013 04-02)
Chap4 new (tran dai's conflicted copy 2013 04-02)Chap4 new (tran dai's conflicted copy 2013 04-02)
Chap4 new (tran dai's conflicted copy 2013 04-02)
 
Chap3 new
Chap3 newChap3 new
Chap3 new
 
Chap2 new
Chap2 newChap2 new
Chap2 new
 
Chap2 new (tran dai's conflicted copy 2013 04-02)
Chap2 new (tran dai's conflicted copy 2013 04-02)Chap2 new (tran dai's conflicted copy 2013 04-02)
Chap2 new (tran dai's conflicted copy 2013 04-02)
 
Chap1 new (tran dai's conflicted copy 2013 04-02)
Chap1 new (tran dai's conflicted copy 2013 04-02)Chap1 new (tran dai's conflicted copy 2013 04-02)
Chap1 new (tran dai's conflicted copy 2013 04-02)
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2
 
Appendix a 2
Appendix a 2Appendix a 2
Appendix a 2
 
Chap8 part ii
Chap8 part iiChap8 part ii
Chap8 part ii
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

Chap8 new

  • 2. Outline     Why approximation algorithms? The vertex cover problem The set cover problem TSP 2
  • 3. Why Approximation Algorithms ?     Many problems of practical significance are NPcomplete but are too important to abandon merely because obtaining an optimal solution is intractable. If a problem is NP-complete, we are unlikely to find a polynomial time algorithm for solving it exactly, but it may still be possible to find near-optimal solution in polynomial time. In practice, near-optimality is often good enough. An algorithm that returns near-optimal solutions is called an approximation algorithm. 3
  • 4. Performance bounds for approximation algorithms      i is an optimization problem instance c(i) be the cost of solution produced by approximate algorithm and c*(i) be the cost of optimal solution. For minimization problem, we want c(i)/c*(i) to be as small as possible. For maximization problem, we want c*(i)/c(i) to be as small as possible. An approximation algorithm for the given problem instance i, has a ratio bound of p(n) if for any input of size n, the cost c of the solution produced by the approximation algorithm is within a factor of p(n) of the cost c* of an optimal solution. That is max(c(i)/c*(i), c*(i)/c(i)) ≤ p(n) 4
  • 5.     Note that p(n) is always greater than or equal to 1. If p(n) = 1 then the approximate algorithm is an optimal algorithm. The larger p(n), the worst algorithm Relative error   We define the relative error of the approximate algorithm for any input size as |c(i) - c*(i)|/ c*(i) We say that an approximate algorithm has a relative error bound of ε(n) if |c(i)-c*(i)|/c*(i)≤ ε(n) 5
  • 6. 1. The Vertex-Cover Problem     Vertex cover: given an undirected graph G=(V,E), then a subset V'⊆V such that if (u,v)∈E, then u∈V' or v ∈V' (or both). Size of a vertex cover: the number of vertices in it. Vertex-cover problem: find a vertex-cover of minimal size. This problem is NP-hard, since the related decision problem is NP-complete 6
  • 7. Approximate vertex-cover algorithm The running time of this algorithm is O(E). 7
  • 8. 8
  • 9. Theorem:   APPROXIMATE-VERTEX-COVER has a ratio bound of 2, i.e., the size of returned vertex cover set is at most twice of the size of optimal vertexcover. Proof:    It runs in poly time The returned C is a vertex-cover. Let A be the set of edges picked in line 4 and C* be the optimal vertex-cover.   Then C* must include at least one end of each edge in A and no two edges in A are covered by the same vertex in C*, so |C*|≥|A|. Moreover, |C|=2|A|, so |C|≤2|C*|. 9
  • 10. The Set Covering Problem   The set covering problem is an optimization problem that models many resource-selection problems. An instance (X, F) of the set-covering problem consists of a finite set X and a family F of subsets of X, such that every element of X belongs to at least one subset in F: X =∪S S∈F  We say that a subset S∈F covers its elements. The problem is to find a minimum-size subset C ⊆ F whose members cover all of X: X =∪S S∈C  We say that any C satisfying the above equation covers X. 10
  • 11. Figure 6.2 An instance {X, F} of the set covering problem, where X consists of the 12 black points and F = { S1, S2, S3, S4, S5, S6}. A minimum size set cover is C = { S3, S4, S5}. The greedy algorithm produces the set C’ = {S1, S4, S5, S3} in order. 11
  • 12. Applications of Set-covering problem     Assume that X is a set of skills that are needed to solve a problem and we have a set of people available to work on it. We wish to form a team, containing as few people as possible, s.t. for every requisite skill in X, there is a member in the team having that skill. Assign emergency stations (fire stations) in a city. Allocate sale branch offices for a company. Schedule for bus drivers. 12
  • 13. A greedy approximation algorithm Greedy-Set-Cover(X, F) 1. U = X 2. C = ∅ 3. while U != ∅ do 4. select an S∈F that maximizes | S ∩ U| 5. U=U–S 6. C = C ∪ {S} 7. return C The algorithm GREEDY-SET-COVER can easily be implemented to run in time complexity in |X| and |F|. Since the number of iterations of the loop on line 3-6 is at most min(|X|, | F|) and the loop body can be implemented to run in time O(| X|,|F|), there is an implementation that runs in time O(|X|,|F| min(|X|,|F|) . 13
  • 14. Ratio bound of Greedy-set-cover  Let denote the dth harmonic number d hd = Σi-11/i   Theorem: Greedy-set-cover has a ratio bound H(max{|S|: S ∈F}) Corollary: Greedy-set-cover has a ratio bound of (ln| X| +1) (Refer to the text book for the proofs) 14
  • 15. 3. The Traveling Salesman Problem  Since finding the shortest tour for TSP requires so much computation, we may consider to find a tour that is almost as short as the shortest. That is, it may be possible to find near-optimal solution.  Example: We can use an approximation algorithm for the HCP. It's relatively easy to find a tour that is longer by at most a factor of two than the optimal tour. The method is based on   the algorithm for finding the minimum spanning tree and an observation that it is always cheapest to go directly from a vertex u to a vertex w; going by way of any intermediate stop v can’t be less expensive. C(u,w) ≤ C(u,v)+ C(v,w) 15
  • 16. APPROX-TSP-TOUR The algorithm computes a near-optimal tour of an undirected graph G. procedure APPROX-TSP-TOUR(G, c); begin select a vertex r ∈ V[G] to be the “root” vertex; grow a minimum spanning tree T for G from root r, using Prim’s algorithm; apply a preorder tree walk of T and let L be the list of vertices visited in the walk; form the halmintonian cycle H that visits the vertices in the order of L. /* H is the result to return * / end A preorder tree walk recursively visits every vertex in the tree, listing a vertex when its first encountered, before any of its children are visited.  16
  • 17. Thí dụ minh họa giải thuật APPROX-TSP-TOUR 17
  • 18. The preorder tree walk is not simple tour, since a node be visited many times, but it can be fixed, the tree walk visits the vertices in the order a, b, c, b, h, b, a, d, e, f, e, g, e, d, a. From this order, we can arrive to the hamiltonian cycle H: a, b, c, h, d, e ,f, g, a. 18
  • 19. The optimal tour The total cost of H is approximately 19.074. An optimal tour H* has the total cost of approximately 14.715. The running time of APPROX-TSP-TOUR is O(E) = O(V2), since the input graph is a complete graph. 19
  • 20. Ratio bound of APPROX-TSP-TOUR  Theorem: APPROX-TSP-TOUR is an approximation algorithm with a ratio bound of 2 for the TSP with triangle inequality.  Proof: Let H* be an optimal tour for a given set of vertices. Since we obtain a spanning tree by deleting any edge from a tour, if T is a minimum spanning tree for the given set of vertices, then c(T) ≤ c(H*) (1) A full walk of T traverses every edge of T twice, we have: c(W) = 2c(T) (2) (1) and (2) imply that: c(W) ≤ 2c(H*) (3)  20
  • 21. But W is not a tour, since it visits some vertices more than once. By the triangle inequality, we can delete a visit to any vertex from W. By repeatedly applying this operation, we can remove from W all but the first visit to each vertex.  Let H be the cycle corresponding to this preorder walk. It is a hamiltonian cycle, since every vertex is visited exactly once. Since H is obtained by deleting vertices from W, we have c(H) ≤ c(W) (4)  From (3) and (4), we conclude: c(H) ≤ 2c(H*) So, APPROX-TSP-TOUR returns a tour whose cost is not more than twice the cost of an optimal tour.  21
  • 22. 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 22