




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





















Analysis and
Design of
Algorithms
Instructor
Prof. Amrinder Arora
Please copy TA on emails
Please feel free to call as well
Available for study sessions
Science and Engineering Hall
Textbook
Second Edition
Cognella Academic Publisher
www.cognella.com
ISBN:
978-1-63487-073-
Knowing that an object exists within a certain
distance from us, in an infinite maze, how can
we find it?
the root in a BFS tree being formed. Its level is
called the current level.
order in which the level nodes were visited,
visit all the unvisited neighbors of x. The newly
visited nodes from this level form a new level
that becomes the next current level.
can be visited.
Step 1.
Observations: The first node visited in each
level is the first node from which to proceed
to visit new nodes.
This suggests that a queue is the proper data
structure to remember the order of the steps.
Procedure BFS(input: graph G)
Queue Q; Integer s, x
while (G has an unvisited node) do
s := an unvisited node
visit(s)
Enqueue(s,Q)
While (Q is not empty) do
x := Dequeue(Q)
For (unvisited neighbor y of x) do
visit(y)
Enqueue(y,Q)
Hamiltonian Cycle
K-clique
K-coloring
Algorithms
Analysis
Asymptotic
NP-
Completene
ss
Design
D&C
Greedy
DP
Graph
B&B
Applications
Done
Done
Starting
today..
Done
Done
Done
Given jobs, resources, and cost matrix (cost if
resource i does job j), how to assign jobs to
resources, such that each job is done by a
different resource, and the overall cost is
minimum?
What is the right D&C strategy?
What is the right BFS strategy?
J1 J2 J3 J4 J
R1 2 4 5 3 11
R2 3 5 6 4 8
R3 4 3 5 7 9
R4 3 4 3 8 12
R5 4 2 6 4 9
Each job must be done – so if we add
minimum cost per job, then that must be
minimum cost
Each person must do a job – so if we add
minimum cost per resource, then that must
be minimum cost
Taking the maximum of these two minimums,
is a good “lower bound”.
Assigning a job to a resource can be a node
in the BFS tree
We need to think about the solution space as
a tree, and define what a node in the tree
means with respect to our problem (job
assignment)
B&B is a general algorithm for finding optimal
solutions of various optimization problems,
especially in discrete and combinatorial
optimization.
2 main steps
Branching
Bounding
(If bounding allows, then) Node Elimination
Given a set of items, each with a weight and
a value, determine which items to include in
a collection so that the total weight is less
than a given limit and the total value is as
large as possible.
Different from fractional knapsack, can only
take or not take an item.
No easy solution – greedy solution may not
be optimal.
3 Items. Knapsack can hold 50 lbs.
Item 1 weighs 10 lbs, worth 60$
Item 2 weighs 20 lbs, worth 100$
Item 3 weighs 30 lbs, worth 120$
Greedy solution: Item 1 + Item 2, worth =
Optimal solution: Item 3 + Item 2, worth =