CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow: Applications
Image Segmentation
Network Flow: Applications
You are given an image as a 2-D matrix of pixels.
We want to determine the foreground and the background
pi
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Computational Intractability
NP and NP-complete
Computational Intractability: Reductions
Polynomial time reduction:
Consider two problems and .
Suppose there is a black box that s
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow: Applications
Survey Design
Network Flow: Applications
Problem: There are customers and products. Each
customer is supposed to review between () and ()
products that he
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Polynomial-time reductions:
Examples
Vertex-cover Vs Set-cover
Computational Intractability: Reduction
Problem(Set-cover): Given a set of elements, a
collection 1, , of subsets of ,
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow: Applications
Halls Theorem
Network Flow: Applications
Halls Theorem: Given any bipartite graph = (, , ),
there is a perfect matching in if and only if for every subset
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow: Applications
Circulation with demands
Network Flow: Applications
Given a weighted directed graph representing a
transportation network.
There are multiple supply nodes
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Computational Intractability: Defining NP
Efficient certification:
We say an algorithm is an efficient certifier for a problem if
the following holds:
is a polynomial time algorit
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Computational Intractability: NP-complete problems
Problem(3-D matching): Given disjoint sets , , and each of
size , and given a set of triples (, , ), determine if there
exist a su
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Computational Intractability
NP-complete problems: -COLORING
Computational Intractability: NP-complete problems
Problem ( -coloring): Given a graph , determine if is
-colorable.
-c
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Linear Programming
Randomized approximation algorithms
Linear Programming: rand. approx.
Recall the 2-SAT problem. Given a 2-SAT formula,
determine if the formula has a satisfying a
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Linear Programming: Solving LP
Recap.
Linear Programming: Solving LP
Standard form: A Linear Program is said to be standard
form if the following holds:
The linear objective functio
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Linear Programming
Solving LP
Linear Programming: Solving LP
Simplex algorithm:
Repeat:
Pivot: Rewrite the LP in slack form such that the objective value of the
basic solution inc
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Homework-5
Claim: If P=NP, then RSA breaks.
Proof idea:
If we can quickly factor (= ), then we can quickly
figure out the secret RSA key.
2. Claim: If P=NP, then we can quickly fac
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Linear Programming
Recap
Linear Programming: Recap.
Problem (LP): Given a linear objective function and a set of
linear constraints, find an assignment for the real valued
variables
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Topics
Greedy Algorithms
Divide and Conquer
Dynamic Programming
Network Flow
Computational intractability
Other topics: Linear Programming
Linear Programming
Linear Programming
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Computational Intractability
NP and NP-completeness
Computational Intractability: NP & NP-complete
NP: A problem is in NP if and only if there is an efficient
certifier for .
NP-co
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow
Strongly polynomial time algorithm for max-flow
Network Flow: Edmonds-Karp
Max-Flow /Edmonds-Karp algorithm
- Start with a flow such that () = 0
- while there is an path
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow: Recap.
Ford-Fulkerson algorithm:
Given network with integer capacities, find a source-to-sink
path and push as much flow along the path as possible.
Update the resid
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Network Flow
Ford-Fulkerson algorithm
Network Flow
Max-Flow /Ford-Fulkerson algorithm
- Start with a flow such that () = 0
- while there is an path in
- Execute the augmenting path
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms: Example
Theorem (Cut Property): Given a weighted graph = ( , )
where all the edge weights are distinct. Consider a non-empty
proper subset of of and = \S. Let be
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms
For some problems, even though the greedy strategy does not give
an optimal solution but it might give a solution that is provably close
to the optimal solution.
Gr
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms: Examples
Huffman Coding
Greedy Algorithms: Huffman Coding
Prefix-free encoding: An encoding is called prefix-free if
for any pair of alphabets (1, 2), (1) is not
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms: Example
Job Scheduling:You are given jobs and you are supposed to
schedule these jobs on a machine. Each job consists of a
duration ( ) and a deadline (). The lat
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms: Example
Fractional Knapsack:You are a thief and you have a sack of
size . There are divisible items. Each item has a
volume () and total value (). How will you ma
CSL 356: Analysis and Design of
Algorithms
Ragesh Jaiswal
CSE, IIT Delhi
Greedy Algorithms
Greedy Algorithms: Introduction
A local (greedy) decision rule leads to a globally optimal solution.
Two ways to show the above property:
Greedy stays ahead.
2. E