SlideShare a Scribd company logo
Approximation Algorithms
Seyed Mohsen Fatemi
91222096
Shahid Beheshti University
NP-Completeness
Brute-force algorithms.
 Develop clever enumeration strategies.
 Guaranteed to find optimal solution.
 No guarantees on running time.
Heuristics.
Develop intuitive algorithms.
Guaranteed to run in polynomial time.
No guarantees on quality of solution.
Approximation algorithms.
• Guaranteed to run in polynomial time.
• Guaranteed to find "high quality" solution, say within 1% of
optimum.
Obstacle: need to prove a solution’s value is close to optimum,
without even knowing what optimum value is!
Combinatorial optimization:
• Scheduling classes
• Planning delivery routes for trucks
• …
Most are NP-hard
In polynomial time, we find a solution whose
value is provably within a "small" factor of the
optimal solution
Dealing with NP-hard problems
Approximation algorithms, vertex cover, and
linear programming
Vertex Cover
• Vertex cover: a subset of vertices which “covers” every edge , An edge is
covered if one of its endpoint is chosen .
• The Minimum Vertex Cover Problem:
Find a vertex cover with minimum number of vertices.
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
lowerbound OPTLP
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Correctness
•… is it a Vertex Cover ?
Approximation alogrithms
Quality of Output
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Performance guarantees
• An Approximation Algorithm is bounded by ρ(n) if for all input of size n ,
the cost c of the solution obtained by the algorithm is within a factor ρ(n) of
the c* of an optimal solution
How good is that?
Typical performance :
within 10% of optimum
Theorem
• There exists an optimal solution s.t. every coordinate is in {0, 0.5, 1} and
there is a polynomial-time algorithm to construct it.
• End of Vertex Cover
The Knapsack Problem
• Given: capacity B knapsack , n items , item i has size si and value vi Place
some items in knapsack Maximize value
• It is NP-hard !
Graphical Representation
Desire: small size, high value
• Naive greedy algorithm
• take by order of increasing size/value
How good is Greedy ?
• Greedy is bad !
Working with Special Cases :
• If all items have the same size… ! Greedy is good.
• If all items have the same value… ! Greedy is good.
• If all items have size=value …
Greedy Algorithm For the Case size=value
• A greedy algorithm for special case size=value Order items by decreasing
value.
• How good is that?
Knapsack special special case
• All items have size = value € {1,2,…, B}
• and in addition B is a "small" integer
Approximation alogrithms
Dynamic programming
• Q: What to remember?
• A: remember total value so far
• A[i,v]=whether v achievable with subset of first i items
• Q: v achievable with subset of first i items iff…
• A: …it depends on whether subset contains i
• If not: v must be reached with first i-1 items
• If yes: v-vi must be reached with first i-1 items
• A[i,v]=whether v achievable with subset of first i items
• A[i,v]= A[i-1,v] or ((v-vi) and A[i-1,v-vi])
Algorithm
Less special special case
• values are small integers
• All values € {1,2,...,N}
N : "small" integer
Dynamic programming
• Q: What to remember?
• A[i,v]= whether v achievable with subset of first i items
• A[i,v]=must remember size
• A[i,v]=min size achievable for subset of first i items of value v
• Q: v,s achievable with subset of first i items iff…
• A: …it depends on whether subset contains i
• If not: v,s reached with first i-1 items
• If yes: v-vi , s-si reached with first i-1 items
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
• Q : How to modify input so that values are small integers?
• A : Scale and round :
**Discard items that don’t fit
**1. Multiply each value by something so that values are small
**2. Round values to integers Dynamic program for the scaled and rounded
problem
Approximation alogrithms
Effect of scaling
• Max scaled value = N
How do we pick N?
• small enough that the runtime is polynomial
• large enough that the resulting set of items has value close to the optimum
Approximation alogrithms
Approximation alogrithms
Analysis
• S: output items
• DP: S optimal for scaled rounded input
• S*: optimal items
• Scaling: S* optimal for scaled unrounded input
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Approximation alogrithms
Lower bound OPT
• Discarded items that don’t fit :
Wrapping Up
Theorem
• Solution to knapsack with value at least 0.99 OPT and runtime O(poly(n))
Approximation alogrithms
Theorem
• this gives a solution to knapsack with value at least 0.999 OPT and with
runtime O(poly(n))
Approximation Scheme
Theorem
• knapsack has an approximation scheme
Approximation alogrithms
Approximation alogrithms
Method
• 1. Simplify the input
• 2. Design algorithm for “simple” inputs
Refrences :
• Approximation Algorithms – Part 1 Coursera
• Introduction to algorithms , CLRS , 3rd ed T.Cormen
• The Design of Approximation Algorithms , David P.Williamson , David
B.Shmoys
• Approximation Algorithms , Vijay V. Vazirani
Good Luck ;)
Teşekkürler
 sağ olasız 

More Related Content

PPTX
DynamicProgramming.pptx
PPT
Greedy Algorithms WITH Activity Selection Problem.ppt
PPT
Greedy algorithms
PPTX
Lecture 23(OBST,knapsack) from DAA for students of CSE
PPTX
Greedy Algorithm - Knapsack Problem
PPTX
Machine Learning
PPTX
AI -learning and machine learning.pptx
DynamicProgramming.pptx
Greedy Algorithms WITH Activity Selection Problem.ppt
Greedy algorithms
Lecture 23(OBST,knapsack) from DAA for students of CSE
Greedy Algorithm - Knapsack Problem
Machine Learning
AI -learning and machine learning.pptx

Similar to Approximation alogrithms (20)

PPTX
machine leraning : main principles and techniques
PPT
PPT
lecture 27
PPTX
Learn from Example and Learn Probabilistic Model
PPTX
Forecasting Rung 1
PDF
CNIT 141: 9. Hard Problems
PPTX
Dynamic Programming
PPT
NaiveBayes this is more functioonal and extraction of same version
PDF
greedy method.pdf
PDF
Analysis and design of algorithms part 4
PDF
Unit7
PPTX
Dynamic programming
PDF
CNIT 141 9. Hard Problems
PPT
NaiveBayes.ppt
PPT
NaiveBayes.ppt Naive Bayes algorithm machine learning
PPT
NaiveBayes.ppt
PPT
NaiveBayes.ppt
PPTX
NP-Completeness-myppt.pptx
machine leraning : main principles and techniques
lecture 27
Learn from Example and Learn Probabilistic Model
Forecasting Rung 1
CNIT 141: 9. Hard Problems
Dynamic Programming
NaiveBayes this is more functioonal and extraction of same version
greedy method.pdf
Analysis and design of algorithms part 4
Unit7
Dynamic programming
CNIT 141 9. Hard Problems
NaiveBayes.ppt
NaiveBayes.ppt Naive Bayes algorithm machine learning
NaiveBayes.ppt
NaiveBayes.ppt
NP-Completeness-myppt.pptx
Ad

Recently uploaded (20)

PDF
Assessment of environmental effects of quarrying in Kitengela subcountyof Kaj...
PPTX
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
PPTX
Introduction to Cardiovascular system_structure and functions-1
PDF
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
PPT
POSITIONING IN OPERATION THEATRE ROOM.ppt
PPTX
Microbiology with diagram medical studies .pptx
DOCX
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
PDF
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
PPTX
7. General Toxicologyfor clinical phrmacy.pptx
PPTX
Overview of calcium in human muscles.pptx
PPTX
famous lake in india and its disturibution and importance
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PDF
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
PDF
Biophysics 2.pdffffffffffffffffffffffffff
PPTX
C1 cut-Methane and it's Derivatives.pptx
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PPTX
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
PDF
Sciences of Europe No 170 (2025)
PPTX
Taita Taveta Laboratory Technician Workshop Presentation.pptx
Assessment of environmental effects of quarrying in Kitengela subcountyof Kaj...
EPIDURAL ANESTHESIA ANATOMY AND PHYSIOLOGY.pptx
Introduction to Cardiovascular system_structure and functions-1
Formation of Supersonic Turbulence in the Primordial Star-forming Cloud
POSITIONING IN OPERATION THEATRE ROOM.ppt
Microbiology with diagram medical studies .pptx
Q1_LE_Mathematics 8_Lesson 5_Week 5.docx
Mastering Bioreactors and Media Sterilization: A Complete Guide to Sterile Fe...
7. General Toxicologyfor clinical phrmacy.pptx
Overview of calcium in human muscles.pptx
famous lake in india and its disturibution and importance
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Cosmic Outliers: Low-spin Halos Explain the Abundance, Compactness, and Redsh...
Biophysics 2.pdffffffffffffffffffffffffff
C1 cut-Methane and it's Derivatives.pptx
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
Vitamins & Minerals: Complete Guide to Functions, Food Sources, Deficiency Si...
Sciences of Europe No 170 (2025)
Taita Taveta Laboratory Technician Workshop Presentation.pptx
Ad

Approximation alogrithms

  • 1. Approximation Algorithms Seyed Mohsen Fatemi 91222096 Shahid Beheshti University
  • 3. Brute-force algorithms.  Develop clever enumeration strategies.  Guaranteed to find optimal solution.  No guarantees on running time. Heuristics. Develop intuitive algorithms. Guaranteed to run in polynomial time. No guarantees on quality of solution. Approximation algorithms. • Guaranteed to run in polynomial time. • Guaranteed to find "high quality" solution, say within 1% of optimum. Obstacle: need to prove a solution’s value is close to optimum, without even knowing what optimum value is!
  • 4. Combinatorial optimization: • Scheduling classes • Planning delivery routes for trucks • … Most are NP-hard
  • 5. In polynomial time, we find a solution whose value is provably within a "small" factor of the optimal solution Dealing with NP-hard problems
  • 6. Approximation algorithms, vertex cover, and linear programming
  • 7. Vertex Cover • Vertex cover: a subset of vertices which “covers” every edge , An edge is covered if one of its endpoint is chosen . • The Minimum Vertex Cover Problem: Find a vertex cover with minimum number of vertices.
  • 22. Correctness •… is it a Vertex Cover ?
  • 28. Performance guarantees • An Approximation Algorithm is bounded by ρ(n) if for all input of size n , the cost c of the solution obtained by the algorithm is within a factor ρ(n) of the c* of an optimal solution
  • 29. How good is that? Typical performance : within 10% of optimum
  • 30. Theorem • There exists an optimal solution s.t. every coordinate is in {0, 0.5, 1} and there is a polynomial-time algorithm to construct it. • End of Vertex Cover
  • 31. The Knapsack Problem • Given: capacity B knapsack , n items , item i has size si and value vi Place some items in knapsack Maximize value • It is NP-hard !
  • 33. Desire: small size, high value • Naive greedy algorithm • take by order of increasing size/value
  • 34. How good is Greedy ? • Greedy is bad !
  • 35. Working with Special Cases : • If all items have the same size… ! Greedy is good. • If all items have the same value… ! Greedy is good. • If all items have size=value …
  • 36. Greedy Algorithm For the Case size=value • A greedy algorithm for special case size=value Order items by decreasing value. • How good is that?
  • 37. Knapsack special special case • All items have size = value € {1,2,…, B} • and in addition B is a "small" integer
  • 39. Dynamic programming • Q: What to remember? • A: remember total value so far • A[i,v]=whether v achievable with subset of first i items
  • 40. • Q: v achievable with subset of first i items iff… • A: …it depends on whether subset contains i • If not: v must be reached with first i-1 items • If yes: v-vi must be reached with first i-1 items
  • 41. • A[i,v]=whether v achievable with subset of first i items • A[i,v]= A[i-1,v] or ((v-vi) and A[i-1,v-vi])
  • 43. Less special special case • values are small integers • All values € {1,2,...,N} N : "small" integer
  • 44. Dynamic programming • Q: What to remember? • A[i,v]= whether v achievable with subset of first i items • A[i,v]=must remember size • A[i,v]=min size achievable for subset of first i items of value v
  • 45. • Q: v,s achievable with subset of first i items iff… • A: …it depends on whether subset contains i • If not: v,s reached with first i-1 items • If yes: v-vi , s-si reached with first i-1 items
  • 49. • Q : How to modify input so that values are small integers? • A : Scale and round : **Discard items that don’t fit **1. Multiply each value by something so that values are small **2. Round values to integers Dynamic program for the scaled and rounded problem
  • 51. Effect of scaling • Max scaled value = N
  • 52. How do we pick N? • small enough that the runtime is polynomial • large enough that the resulting set of items has value close to the optimum
  • 55. Analysis • S: output items • DP: S optimal for scaled rounded input • S*: optimal items • Scaling: S* optimal for scaled unrounded input
  • 60. Lower bound OPT • Discarded items that don’t fit :
  • 62. Theorem • Solution to knapsack with value at least 0.99 OPT and runtime O(poly(n))
  • 64. Theorem • this gives a solution to knapsack with value at least 0.999 OPT and with runtime O(poly(n))
  • 66. Theorem • knapsack has an approximation scheme
  • 69. Method • 1. Simplify the input • 2. Design algorithm for “simple” inputs
  • 70. Refrences : • Approximation Algorithms – Part 1 Coursera • Introduction to algorithms , CLRS , 3rd ed T.Cormen • The Design of Approximation Algorithms , David P.Williamson , David B.Shmoys • Approximation Algorithms , Vijay V. Vazirani
  • 71. Good Luck ;) Teşekkürler  sağ olasız 