Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 19
Shortest Paths in Directed Graphs with Negative Weights
1
Optimal subpath property
Property
is also
shortestpath
path.
Every subpath
If of
, then
is thea shortest
from to .
2
Theorem: Given a

Design
and
Analysis
of
Algorithms
Practice-sheet 6: Maximum Flow
1. (Flow fundamental) Suppose you are given a directed graph G = (V, E) with a
positive integer capacity ce on each edge, a designated source s V , and a designated
sink t V . You are also g

IIT Kanpur , CSE Department
Assignment
Pawan Kumar Patel - 14453
Ameya Loya - 14080
August 28, 2016
1
1
Hierarchical metric
Given: A complete graph G, having n vertices. A mapping d : V V R+ such that
d(vi , vj ) 0 if i 6= j and d(vi , vj ) = 0 if i = j w

IIT Kanpur , CSE Department
Assignment
Pawan Kumar Patel - 14453
Ameya Loya - 14080
November 1, 2016
i
1
Dynamic Reachability
Algorithm 1 Algorithm to find the set set of vertices reachable from s
1: procedure Update-R(i,j )
2:
if R[i ]=true and R[j ]=fal

IIT Kanpur , CSE Department
Assignment
Pawan Kumar Patel - 14453
Ameya Loya - 14080
October 7, 2016
1
1
A Job Scheduling Problem
1.2.1
Let S = cfw_j1 , j2 , . . . , jk be a optimal solution. We prove that there exists an optimal solution
such the deadlin

IIT Kanpur , CSE Department
Assignment
Pawan Kumar Patel - 14453
Ameya Loya - 14080
September 4, 2016
1
Contents
2
1
Unique path ids in a DAG
1.1
Overview of Solution:
First of all we will do a topological sort in given the DAG, then find the source verte

CS345/CS345A: Design and Analysis of Algorithms
Mid semester exam 2014
Name:
Roll No.:
1. (marks=7) There are n jobs. There are n PCs and one supercomputer. Each job consists of two
stages: first it needs to be preprocessed on the supercomputer, and then

Design
and
Analysis
of
Algorithms
Practice-sheet 2 : Augmented Binary Search Trees
1. Alternatives solutions for find-rank operation
In the class, we discussed the operation find-rank(T, x) on a red-black tree. We
found that we can perform this operation

Design
and
Analysis
of
Algorithms
Practice-sheet 1 : Divide and Conquer
1. Given an array A storing n distinct numbers. A pair (i, j) where 0 i < j n 1,
is said to be an inversion if A[i] > A[j]. Design an O(n log n) time algorithm to count
all inversions

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 30
Maximum Flow
Applications
Generalization
1
INTEGRALITY OF MAX-FLOW
A useful tool for many applications of Max-Flow
2
Integrality of max-flow
Theorem: Given a network =(,), and two vertices ,
if

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 28
Polynomial time algorithms for Maximum Flow
(By Carefully choosing the augmenting paths in FF-algorithm)
1
Ford Fulkerson algorithm
Ford-Fulkerson-algo(,)
cfw_ ;
While (there is - path in ) do

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 27
Analysis of Ford Fulkerson algorithm
(Max-Flow Min-Cut Theorem)
1
FORD FULKERSON ALGORITHM
A simple path based algorithm
+
Residual Network
2
Residual network
Let =(, ) be a network
Let be any va

Design and Analysis of Algorithms
CS345
Lecture 3
Non-dominated points problem O( ) algorithm
Multiplication of two polynomials problem
1
Recap from Lecture 1
2
The Non Dominated Points
Given
a set of points
Definition: point is said to be non-dominated

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 7
Augmented BST (Final lecture)
Interval tree: an augmented BST used for geometric problems
1
Motivation through Examples
Example 1: Given a set of axis-parallel rectangles,
determine if any two of

Algorithms Theory
08 Fibonacci Heaps
Prof. Dr. S. Albers
Winter term 07/08
Priority queues: operations
Priority queue Q
Operations:
Q.initialize(): initializes an empty queue Q
Q.isEmpty(): returns true iff Q is empty
Q.insert(e): inserts element e into Q

CS345 : Algorithms II
Semester I, 2016-17, CSE, IIT Kanpur
Assignment 4
Deadline : 6:00 PM, Friday, 7 October 2016
Important Guidelines:
It is only through the assignments that one learns the most about the algorithms and data structures.
You are advised

CS345/CS345A : Design and Analysis of Algorithms
Semester I, 2016-17, CSE, IIT Kanpur
Theoretical Assignment VI
Deadline : 6:00PM, 7th November
Important Guidelines:
It is only through the assignments that one learns the most about the algorithms and dat

CS345 : Algorithms II
Semester I, 2016-17, CSE, IIT Kanpur
Assignment 5
Deadline : 6:00 PM, Friday, 27 October 2016
Important Guidelines:
It is only through the assignments that one learns the most about the algorithms and data structures. You
are advise

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 5
Homework from the last class
Data Structures : The power of Binary Search Tree
1
Sub-problem 2
Given a polynomial of degree less than in (point,value) representation,
Compute its coefficient r

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 10
Greedy Strategies
Huffman code : A data compression algorithm (continued. From last lecture)
1
Greedy Algorithms
2
To prove that a greedy strategy works
P: a given optimization problem
instanc

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 6
Augmented BST for
Dynamic sequences
Orthogonal range searching
1
The fundamental question we answered in last
class
Question: What makes BST pervasive in the world of data structures ?
Answer: Aug

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 9
Job scheduling problem
Huffman code : A data compression algorithm
Revisiting an algorithm paradigm
1
A Job scheduling problem
2
are jobs:
, ,
There
Each job takes certain time for execution.
Ea

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 8
Synchronizing an electric circuit : A problem
Proof of correctness of an algorithm
1
Motivation
Study this lecture slowly, steadily, and try to answer each question posed in the slides.
Revisit

Design and Analysis of Algorithms
CS345
Lecture 2
Closest Pair problem: O( )
Convex Hull problem
Non-dominated points problem
1
Recap from Lecture 1
2
The Closest Pair Problem
3
The divide and conquer
points
points
4
The divide and conquer
5
Divide and Co

Design and Analysis of Algorithms
CS345
Lecture 1
Overview of the course
Closest Pair problem
1
Algorithms
2
Algorithm Paradigm
Motivation:
Many problems whose algorithms are based on a common approach.
A need of a systematic study of the characteristic

Design and Analysis of Algorithms
CS345
Lecture 4
Multiplication of two polynomials problem
The most nontrivial application of
Divide and Conquer paradigm
1
Recap from Lecture 1
2
An algorithm for
multiplying two polynomials
3
Multiplying two polynomials

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 32
Applications and Generalization of Maximum Flow III
(Last lecture of the topic)
1
Applications of Min-cut
These applications are arguably the most non-trivial applications.
Try to realize this

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 31
Applications and Generalization of Maximum Flow - II
1
APPLICATIONS OF MAX-FLOW
Maximum no. of Edge Disjoint paths from to
2
Maximum no. of Edge Disjoint paths from to
Definition: Two paths are

Design and Analysis of Algorithms
(CS345/CS345A)
Lecture 14
Depth First Search in Directed Graph - III
1
Application - III
Computing Strongly connected components
of a directed graph.
Strongly connected components
Definition: Two vertices and are said to