SlideShare a Scribd company logo
1 of 25
Approximation
Algorithms
Bipesh Subedi
ME 2021, Computer Engineering
DoCSE
Outline
2
➔ Introduction
➔ Optimization Problem
➔ Statement
➔ Approximation Ratio
➔ Examples of Approximation algorithms
➔ Travelling Salesman Problem (TSP)
➔ Analysis
➔ Application
➔ Pros and Cons
➔ ‘Conclusion
Introduction
Approximation algorithms refers to the efficient algorithms that finds a
solution to an optimization problems ( in particular NP-Hard problems )
that is provably close to optimal solution.
When it is used ?
➔ When finding an optimal solution is very difficult
➔ In some cases, where exact solution is not needed and near-
optimal solution can be found quickly
3
➔ For NP-Complete problems, there is possibly no
polynomial-time algorithms to find an optimal solution.
➔ The idea of approximation algorithms is to develop
polynomial-time algorithms to get near optimal solution.
4
Optimization Problem
It refers to the problem of finding best option/solution among all
feasible/possible solutions.
Various important applied problems involve in finding the best possible way
to accomplish the task which is often done by finding the maximum or
minimum values to a function.
➔ Maximization Problem : Finding the maximum optimal value
➔ Minimization Problem : Finding the minimal optimum value
For example: the minimum time to make a certain journey, the minimum
cost for doing a task, the maximum power that can be generated by a
device, and so on.
5
Statement
➔ An algorithm for a problem of size n has an approximation ratio
ρ(n) if for any input, the algorithm produces a solution with cost
C that satisfies the property:
Where Copt is the cost of optimal solution and ρ(n) is a constant or a
function of n.
6
Approximation Ratio
➔ The approximation ratio of an algorithm is the ratio
between the result obtained by the algorithm and the
optimal cost.
Significance
➔ Performance Guarantee:
It guarantees that the result produced by the approximation
algorithm is not going to be worse than a factor of ρ(n)
compared to the optimal solution.
7
The algorithm with approximation ratio ρ(n) is then called
ρ(n)-approximation algorithm.
Here we will consider our approximation algorithm to have
constant approximation ratio.
For example: If ρ(n) = 2 then,
For maximization problem : our solution will be no less than half
the optimal solution. ( Copt/C <= 2 )
For minimization problem : our solution will be no more than
twice the optimal solution. (C/Copt <= 2)
8
Range of Approximation ratio
➔ If ρ(n) =1 then,
The algorithm can always find a
optimal solution
➔ If ρ(n) >1 then,
It gives the approximation in which
the algorithm works.
9
10
Examples of Approximation algorithms
➔ Travelling salesman Problem
➔ Vertex-Cover Problem
➔ Bin Packing
Travelling Salesman Problem (TSP)
A salesman should visit all the cities exactly once starting from one
city and return back to the starting city such that the total length of the
tour should be minimum.
➔ It is a NP-Complete problem so, there is no polynomial time.
➔ Use an approximation algorithm with a constant approximation
ratio.
11
Special Case of
Travelling
Salesman
Problem (TSP)
Triangle Inequality Property
a + b >= c
b + c >= a
a + c >= b
12
Approach
13
Step 1: Start with a complete graph.
Step 2: Compute a Minimum Spanning
Tree (MST) using algorithms like Prim’s,
kruskal’s.
Step 3: Perform a Depth-First Search
(DFS) traversal.
Step 4: Delete duplicate vertices.
Step 5: Join the edges in the order to
obtain approx. tour walk.
Given a weighted, undirected graph,
start from certain vertex, find a
minimum route to visit each vertices
once, and return to the original
vertex.
14
Computing Minimum Spanning Tree
Kruskal’s algorithm
Steps:
1. Sort all the edges in non-decreasing order
of their weight.
2. Pick the smallest edge. Check if it forms a
cycle in the spanning tree formed so far. If no
cycle is formed, include this edge. Otherwise,
discard it.
3. Repeat step 2 until it is a spanning tree.
15
After computing the
minimum spanning tree ,
we perform a depth-first
search in the MST
starting from a vertex A.
16
MST-DFS
17
A -> B -> D -> B
18
A -> B -> D -> B -> E -> B -> A
19
A -> B -> D -> B -> E -> B -> A -> C -> A
After deleting duplicate vertices we
get, A -> B -> D -> E -> C -> A path.
Joining the edges in the above
order we obtain the approx. tour
route.
20
Analysis
➔ Depth first tree tour (DFTT) length is exactly twice the MST’s weight.
➔ MST weight is not more than the length of optimal tour
➔ The tour length is at most twice the optimal length i.e C <= 2 x Copt
So, in this case ρ(n) = 2
Cost found by the APPROX-MST-DFS algorithm :
C = 15 + 10 + 25 + 25 + 30 = 105
Optimal cost ( Copt ) = Sum of MST weights = 15 + 10 + 25 + 10 = 60
C/Copt <= ρ(n)
105/60 <= 2
1.75 <= 2
21
➔ For companies like FedEx and their competitors traveling
salesman problem is used as a reference to solve related
/similar problems.
➔ Can be used in network design and routing purposes.
➔ Used in astronomy to determine the fastest way of drilling an
aluminium disk placed at the focal point of telescope for each
spot of interest to collect the light from the galaxy or star over
a given period of time .
22
Application
Pros
➔ Deals with NP- Complete
problems
➔ Finds solutions which are close
to optimal solution in
polynomial time
➔ Cost Effective
Cons
➔ This technique does not
guarantee the best solution
➔ May not be useful in all
practical application
23
Conclusion
To conclude we can say that the goal of an approximation
algorithm is to come as close as possible to the optimum value
in a reasonable amount of time which is at the most polynomial
time.
24
Thank you !!
25

More Related Content

What's hot

Assignment problem branch and bound.pptx
Assignment problem branch and bound.pptxAssignment problem branch and bound.pptx
Assignment problem branch and bound.pptx
KrishnaVardhan50
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
 

What's hot (20)

Greedy algorithm
Greedy algorithmGreedy algorithm
Greedy algorithm
 
Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)Travelling SalesMan Problem(TSP)
Travelling SalesMan Problem(TSP)
 
9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Dynamic pgmming
Dynamic pgmmingDynamic pgmming
Dynamic pgmming
 
Vertex cover Problem
Vertex cover ProblemVertex cover Problem
Vertex cover Problem
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Travelling salesman problem
Travelling salesman problem Travelling salesman problem
Travelling salesman problem
 
Introduction to dynamic programming
Introduction to dynamic programmingIntroduction to dynamic programming
Introduction to dynamic programming
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 
Assignment problem branch and bound.pptx
Assignment problem branch and bound.pptxAssignment problem branch and bound.pptx
Assignment problem branch and bound.pptx
 
Rsa cryptosystem
Rsa cryptosystemRsa cryptosystem
Rsa cryptosystem
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
NP completeness
NP completenessNP completeness
NP completeness
 
Vertex cover problem
Vertex cover problemVertex cover problem
Vertex cover problem
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Traveling Salesman Problem
Traveling Salesman Problem Traveling Salesman Problem
Traveling Salesman Problem
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
 
Graph theory - Traveling Salesman and Chinese Postman
Graph theory - Traveling Salesman and Chinese PostmanGraph theory - Traveling Salesman and Chinese Postman
Graph theory - Traveling Salesman and Chinese Postman
 
Tsp branch and-bound
Tsp branch and-boundTsp branch and-bound
Tsp branch and-bound
 

Similar to Approximation algorithms

clear allclc Ex2-1 A) Compute the 5 gravity profiles.docx
clear allclc Ex2-1 A)  Compute the 5 gravity profiles.docxclear allclc Ex2-1 A)  Compute the 5 gravity profiles.docx
clear allclc Ex2-1 A) Compute the 5 gravity profiles.docx
monicafrancis71118
 
ETCS262A-Analysis of design Algorithm.pptx
ETCS262A-Analysis of design Algorithm.pptxETCS262A-Analysis of design Algorithm.pptx
ETCS262A-Analysis of design Algorithm.pptx
RahulSingh190790
 

Similar to Approximation algorithms (20)

NP-Completeness - II
NP-Completeness - IINP-Completeness - II
NP-Completeness - II
 
UNIT-II.pptx
UNIT-II.pptxUNIT-II.pptx
UNIT-II.pptx
 
Unit 3- Greedy Method.pptx
Unit 3- Greedy Method.pptxUnit 3- Greedy Method.pptx
Unit 3- Greedy Method.pptx
 
Analysis of Algorithm
Analysis of AlgorithmAnalysis of Algorithm
Analysis of Algorithm
 
Combinatorial Optimization
Combinatorial OptimizationCombinatorial Optimization
Combinatorial Optimization
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design Patterns
 
Dynamic programmng2
Dynamic programmng2Dynamic programmng2
Dynamic programmng2
 
clear allclc Ex2-1 A) Compute the 5 gravity profiles.docx
clear allclc Ex2-1 A)  Compute the 5 gravity profiles.docxclear allclc Ex2-1 A)  Compute the 5 gravity profiles.docx
clear allclc Ex2-1 A) Compute the 5 gravity profiles.docx
 
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
 
ETCS262A-Analysis of design Algorithm.pptx
ETCS262A-Analysis of design Algorithm.pptxETCS262A-Analysis of design Algorithm.pptx
ETCS262A-Analysis of design Algorithm.pptx
 
Greedymethod
GreedymethodGreedymethod
Greedymethod
 
Particle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman ProblemParticle Swarm Optimization to Solve Multiple Traveling Salesman Problem
Particle Swarm Optimization to Solve Multiple Traveling Salesman Problem
 
Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.ppt
 
Computer Science Exam Help
Computer Science Exam Help Computer Science Exam Help
Computer Science Exam Help
 
APLICACIONES DE LA DERIVADA EN LA CARRERA DE (Mecánica, Electrónica, Telecomu...
APLICACIONES DE LA DERIVADA EN LA CARRERA DE (Mecánica, Electrónica, Telecomu...APLICACIONES DE LA DERIVADA EN LA CARRERA DE (Mecánica, Electrónica, Telecomu...
APLICACIONES DE LA DERIVADA EN LA CARRERA DE (Mecánica, Electrónica, Telecomu...
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
 
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First SearchGraph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First Search
 
Divide and Conquer / Greedy Techniques
Divide and Conquer / Greedy TechniquesDivide and Conquer / Greedy Techniques
Divide and Conquer / Greedy Techniques
 
Pintu ram
Pintu ramPintu ram
Pintu ram
 

Recently uploaded

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 

Recently uploaded (20)

Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 

Approximation algorithms

  • 2. Outline 2 ➔ Introduction ➔ Optimization Problem ➔ Statement ➔ Approximation Ratio ➔ Examples of Approximation algorithms ➔ Travelling Salesman Problem (TSP) ➔ Analysis ➔ Application ➔ Pros and Cons ➔ ‘Conclusion
  • 3. Introduction Approximation algorithms refers to the efficient algorithms that finds a solution to an optimization problems ( in particular NP-Hard problems ) that is provably close to optimal solution. When it is used ? ➔ When finding an optimal solution is very difficult ➔ In some cases, where exact solution is not needed and near- optimal solution can be found quickly 3
  • 4. ➔ For NP-Complete problems, there is possibly no polynomial-time algorithms to find an optimal solution. ➔ The idea of approximation algorithms is to develop polynomial-time algorithms to get near optimal solution. 4
  • 5. Optimization Problem It refers to the problem of finding best option/solution among all feasible/possible solutions. Various important applied problems involve in finding the best possible way to accomplish the task which is often done by finding the maximum or minimum values to a function. ➔ Maximization Problem : Finding the maximum optimal value ➔ Minimization Problem : Finding the minimal optimum value For example: the minimum time to make a certain journey, the minimum cost for doing a task, the maximum power that can be generated by a device, and so on. 5
  • 6. Statement ➔ An algorithm for a problem of size n has an approximation ratio ρ(n) if for any input, the algorithm produces a solution with cost C that satisfies the property: Where Copt is the cost of optimal solution and ρ(n) is a constant or a function of n. 6
  • 7. Approximation Ratio ➔ The approximation ratio of an algorithm is the ratio between the result obtained by the algorithm and the optimal cost. Significance ➔ Performance Guarantee: It guarantees that the result produced by the approximation algorithm is not going to be worse than a factor of ρ(n) compared to the optimal solution. 7
  • 8. The algorithm with approximation ratio ρ(n) is then called ρ(n)-approximation algorithm. Here we will consider our approximation algorithm to have constant approximation ratio. For example: If ρ(n) = 2 then, For maximization problem : our solution will be no less than half the optimal solution. ( Copt/C <= 2 ) For minimization problem : our solution will be no more than twice the optimal solution. (C/Copt <= 2) 8
  • 9. Range of Approximation ratio ➔ If ρ(n) =1 then, The algorithm can always find a optimal solution ➔ If ρ(n) >1 then, It gives the approximation in which the algorithm works. 9
  • 10. 10 Examples of Approximation algorithms ➔ Travelling salesman Problem ➔ Vertex-Cover Problem ➔ Bin Packing
  • 11. Travelling Salesman Problem (TSP) A salesman should visit all the cities exactly once starting from one city and return back to the starting city such that the total length of the tour should be minimum. ➔ It is a NP-Complete problem so, there is no polynomial time. ➔ Use an approximation algorithm with a constant approximation ratio. 11
  • 12. Special Case of Travelling Salesman Problem (TSP) Triangle Inequality Property a + b >= c b + c >= a a + c >= b 12
  • 13. Approach 13 Step 1: Start with a complete graph. Step 2: Compute a Minimum Spanning Tree (MST) using algorithms like Prim’s, kruskal’s. Step 3: Perform a Depth-First Search (DFS) traversal. Step 4: Delete duplicate vertices. Step 5: Join the edges in the order to obtain approx. tour walk.
  • 14. Given a weighted, undirected graph, start from certain vertex, find a minimum route to visit each vertices once, and return to the original vertex. 14
  • 15. Computing Minimum Spanning Tree Kruskal’s algorithm Steps: 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest edge. Check if it forms a cycle in the spanning tree formed so far. If no cycle is formed, include this edge. Otherwise, discard it. 3. Repeat step 2 until it is a spanning tree. 15
  • 16. After computing the minimum spanning tree , we perform a depth-first search in the MST starting from a vertex A. 16
  • 17. MST-DFS 17 A -> B -> D -> B
  • 18. 18 A -> B -> D -> B -> E -> B -> A
  • 19. 19 A -> B -> D -> B -> E -> B -> A -> C -> A
  • 20. After deleting duplicate vertices we get, A -> B -> D -> E -> C -> A path. Joining the edges in the above order we obtain the approx. tour route. 20
  • 21. Analysis ➔ Depth first tree tour (DFTT) length is exactly twice the MST’s weight. ➔ MST weight is not more than the length of optimal tour ➔ The tour length is at most twice the optimal length i.e C <= 2 x Copt So, in this case ρ(n) = 2 Cost found by the APPROX-MST-DFS algorithm : C = 15 + 10 + 25 + 25 + 30 = 105 Optimal cost ( Copt ) = Sum of MST weights = 15 + 10 + 25 + 10 = 60 C/Copt <= ρ(n) 105/60 <= 2 1.75 <= 2 21
  • 22. ➔ For companies like FedEx and their competitors traveling salesman problem is used as a reference to solve related /similar problems. ➔ Can be used in network design and routing purposes. ➔ Used in astronomy to determine the fastest way of drilling an aluminium disk placed at the focal point of telescope for each spot of interest to collect the light from the galaxy or star over a given period of time . 22 Application
  • 23. Pros ➔ Deals with NP- Complete problems ➔ Finds solutions which are close to optimal solution in polynomial time ➔ Cost Effective Cons ➔ This technique does not guarantee the best solution ➔ May not be useful in all practical application 23
  • 24. Conclusion To conclude we can say that the goal of an approximation algorithm is to come as close as possible to the optimum value in a reasonable amount of time which is at the most polynomial time. 24