SlideShare a Scribd company logo
Analysis and
Design of
Algorithms
BREADTH FIRST SEARCH,
BRANCHING AND BOUNDING
 Instructor
Prof. Amrinder Arora
amrinder@gwu.edu
Please copy TA on emails
Please feel free to call as well

 Available for study sessions
Science and Engineering Hall
GWU
Algorithms Graph Traversal Techniques, Branch & Bound 2
LOGISTICS
Algorithms
Analysis
Asymptotic
NP-
Completeness
Design
D&C
Greedy
DP
Graph
B&B
Applications
Algorithms Graph Traversal Techniques, Branch & Bound 3
WHERE WE ARE
 Done
 Done
 DFS, BFS
 Done
 Done
Knowing that an object exists within a certain
distance from us, in an infinite maze, how can we
find it?
Algorithms Graph Traversal Techniques, Branch & Bound 4
INFINITE MAZE
1. Select an unvisited node s, visit it, have it be the
root in a BFS tree being formed. Its level is called
the current level.
2. From each node x in the current level, in the 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.
3. Repeat the previous step until no more nodes can
be visited.
4. If there are still unvisited nodes, repeat from Step
1.
Algorithms Graph Traversal Techniques, Branch & Bound 5
BREADTH FIRST SEARCH (BFS)
 http://commons.wikimedia.org/wiki/File:Breadth-
First-Search-Algorithm.gif
 http://www.cs.sunysb.edu/~skiena/combinatorica/a
nimations/anim/bfs.gif
Algorithms Graph Traversal Techniques, Branch & Bound 6
BFS EXAMPLE
 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.
Algorithms Graph Traversal Techniques, Branch & Bound 7
BFS IMPLEMENTATION
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)
Algorithms Graph Traversal Techniques, Branch & Bound 8
BFS PSEUDOCODE
 Robotics
 Optimization problems using Branch and Bound
Algorithms Graph Traversal Techniques, Branch & Bound 9
BFS APPLICATIONS
 Hamiltonian Cycle
 K-clique
 K-coloring
Algorithms Graph Traversal Techniques, Branch & Bound 10
OTHER GRAPH PROBLEMS
Algorithms
Analysis
Asymptotic
NP-
Completeness
Design
D&C
Greedy
DP
Graph
B&B
Applications
Algorithms Graph Traversal Techniques, Branch & Bound 11
WHERE WE ARE
 Done
 Done
 Starting today..
 Done
 Done
 Done
 A systematic method for solving optimization problems
 A general optimization technique that applies where the
greedy method and dynamic programming fail.
 Much slower – often leads to exponential time
complexities in the worst case. If applied carefully, can
lead to algorithms that run reasonably fast on average.
 General idea of B&B is a BFS-like search for the optimal
solution, but not all nodes get expanded.
 Carefully selected criterion determines which node to expand and
when
 Another criterion tells the algorithm when an optimal solution has
been found.
Algorithms Graph Traversal Techniques, Branch & Bound 12
BRANCH AND BOUND
 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?
Algorithms Graph Traversal Techniques, Branch & Bound 13
B&B FOR JOB ASSIGNMENT
J1 J2 J3 J4 J5
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
What is the lower bound?
[In other words, how much will it cost at
minimum to do the job assignment?]
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”.
Algorithms Graph Traversal Techniques, Branch & Bound 14
LOWER BOUND
 Any random assignment can be an upper bound
 Or, we can use a greedy algorithm for upper bound.
 In the context of a minimization problem, upper
bound means: “Here is a solution that I have already
found. We are not interested in solutions that are
more expensive than this.” So, in other words, this
solution now defines the highest cost (the upper
bound on cost) that we are willing to pay.
 If we find an even better solution, then we will
decrease our upper bound.
Algorithms Graph Traversal Techniques, Branch & Bound 15
UPPER 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)
Algorithms Graph Traversal Techniques, Branch & Bound 16
BRANCHING
 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
Algorithms Graph Traversal Techniques, Branch & Bound 17
MORE.. (FROM WIKIPEDIA)
 We can consider a maximization problem just as
easily in B&B as well.
 In case of a maximization problem, the “lower
bound” comes from a known solution. The “upper
bound” comes from a theoretical/analytical solution
that typically relaxes some constraint.
 Lower bound signifies: A solution we already know exists
 Upper bound signifies: Maximum value we could obtain, even if
some constraints were relaxed.
 An example of a maximization problem is a 0/1
knapsack problem.
Algorithms Graph Traversal Techniques, Branch & Bound 18
B&B FOR MAXIMIZATION PROBLEMS
 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.
Algorithms Graph Traversal Techniques, Branch & Bound 19
0/1 KNAPSACK PROBLEM
 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 = $160
 Optimal solution: Item 3 + Item 2, worth = $220
Algorithms Graph Traversal Techniques, Branch & Bound 20
0/1 KNAPSACK EXAMPLE
 Given a complete graph with n vertices, the
salesperson wishes to make a tour, visiting each city
exactly once and finishing at the city he starts from.
Cost of going from city i to city j = c(i,j).
Algorithms Graph Traversal Techniques, Branch & Bound 21
TRAVELING SALESPERSON PROBLEM (TSP)
 Input: n jobs, n employees, and an n x n matrix A
where Aij be the cost if person i performs job j.
 Problem: Find a one-to-one matching of the n
employees to the n jobs so that the total cost is
minimized.
 Formally, find a permutation f such that C(f), where
C(f)=A1f(1) + A2f(2) + ... + Anf(n) is minimized.
Algorithms Graph Traversal Techniques, Branch & Bound 22
JOB ASSIGNMENT PROBLEM
 Do a Breadth First Search
 Evaluate each node for upper and lower bounds
 Branch into the “best” node
 Terminate if solution meets performance parameters
Algorithms Graph Traversal Techniques, Branch & Bound 23
BRANCH AND BOUND TEMPLATE
 Branch and Bound depends upon being able to
“bound” each node in the search tree, so that we can
evaluate whether or not to expand it.
 Lower bound and upper bound depend on the
problem
Algorithms Graph Traversal Techniques, Branch & Bound 24
BRANCH AND BOUND TEMPLATE (CONT.)
 Using a mixture of upper and lower bounds, we can
find when might be a right time to terminate the
search.
Algorithms Graph Traversal Techniques, Branch & Bound 25
TERMINATION CRITERIA
 B&B is an interesting technique that uses BFS and
bounding to eliminate the nodes in the search tree.
 Can solve problems that are intrinsically harder.
 Time complexity may not be polynomial, but may be
practical.
 We can return an approximate, usable solution with
some bound on performance.
 Developing interesting bounds depends upon the
problem and uses problem specific insights.
Algorithms Graph Traversal Techniques, Branch & Bound 26
SUMMARY
Algorithms
Analysis
Asymptotic
NP-
Completeness
Design
D&C
Greedy
DP
Graph
B&B
Applications
Algorithms Graph Traversal Techniques, Branch & Bound 27
WHERE WE ARE
 Done
 Done
 Done
 Done
 Done
 Done
 Job Assignment problem, Branch and Bound
 Review slides again – Be ready to discuss lower
bound and upper bounds
 http://en.wikipedia.org/wiki/Branch_and_bound
 “An Automatic Method of Solving Discrete
Programming Problems”
 http://rjlipton.wordpress.com/2012/12/19/branch-
and-bound-why-does-it-work/
 Preview: NP completeness and lower bound for coins
problem.
Algorithms Graph Traversal Techniques, Branch & Bound 28
READING ASSIGNMENT/PREVIEW

More Related Content

PPTX
NP-Completeness - II
PPTX
Dynamic Programming - Part II
PPTX
Introduction to Algorithms and Asymptotic Notation
PPTX
Asymptotic Notation and Data Structures
PPTX
Dynamic Programming - Part 1
PPT
Analysis of Algorithm
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
PDF
Branch and bound technique
NP-Completeness - II
Dynamic Programming - Part II
Introduction to Algorithms and Asymptotic Notation
Asymptotic Notation and Data Structures
Dynamic Programming - Part 1
Analysis of Algorithm
Graph Traversal Algorithms - Depth First Search Traversal
Branch and bound technique

What's hot (19)

PPTX
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
PPTX
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
PDF
Backtracking & branch and bound
PDF
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
PDF
Design & Analysis Of Algorithm
PDF
01. design & analysis of agorithm intro & complexity analysis
PDF
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
PDF
Cs6402 design and analysis of algorithms may june 2016 answer key
PDF
design and analysis of algorithm
PPT
Complexity of Algorithm
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
PPTX
Greedy Algorithms
PDF
PPTX
Design and Analysis of Algorithms
PDF
Skiena algorithm 2007 lecture16 introduction to dynamic programming
PPT
Design and Analysis of Algorithms
PPT
Basic terminologies & asymptotic notations
PPTX
Comparitive Analysis of Algorithm strategies
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Backtracking & branch and bound
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Design & Analysis Of Algorithm
01. design & analysis of agorithm intro & complexity analysis
QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS
Cs6402 design and analysis of algorithms may june 2016 answer key
design and analysis of algorithm
Complexity of Algorithm
DESIGN AND ANALYSIS OF ALGORITHMS
Greedy Algorithms
Design and Analysis of Algorithms
Skiena algorithm 2007 lecture16 introduction to dynamic programming
Design and Analysis of Algorithms
Basic terminologies & asymptotic notations
Comparitive Analysis of Algorithm strategies
Ad

Similar to Graph Traversal Algorithms - Breadth First Search (20)

PPT
Branch and bound
PDF
heuristic search Techniques and game playing.pdf
PPT
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
PPTX
Problem Solving through Search - Uninformed Search
PDF
Ai1.pdf
PPTX
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPTX
Unit ii-ppt
PPTX
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
PPTX
Breadth First Search with example and solutions
PPT
Unit-2 Branch & Bound Design of Algorithms.ppt
PPTX
Branch and bound technique
PPS
Greedy Algorithms with examples' b-18298
PDF
Analysis of Pathfinding Algorithms
PPTX
Data Structures - Lecture 10 [Graphs]
PPTX
ETCS262A-Analysis of design Algorithm.pptx
PPTX
Algorithms Design Patterns
PDF
artificial intelligence MTE E06_lec 3 _250225_114726.pdf
PPTX
unit 2 ai artificial intelligence 1.pptx
PPTX
DATA STRUCTURES.pptx
PPTX
UNIT II ARTIFICIQL INTELLIGENCE SEARCH STRATEGIES OSMANIA UNIVERSITY
Branch and bound
heuristic search Techniques and game playing.pdf
fdocuments.in_branch-and-bound-design-and-analysis-of-alogorithm.ppt
Problem Solving through Search - Uninformed Search
Ai1.pdf
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
Unit ii-ppt
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
Breadth First Search with example and solutions
Unit-2 Branch & Bound Design of Algorithms.ppt
Branch and bound technique
Greedy Algorithms with examples' b-18298
Analysis of Pathfinding Algorithms
Data Structures - Lecture 10 [Graphs]
ETCS262A-Analysis of design Algorithm.pptx
Algorithms Design Patterns
artificial intelligence MTE E06_lec 3 _250225_114726.pdf
unit 2 ai artificial intelligence 1.pptx
DATA STRUCTURES.pptx
UNIT II ARTIFICIQL INTELLIGENCE SEARCH STRATEGIES OSMANIA UNIVERSITY
Ad

More from Amrinder Arora (20)

PPTX
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
PDF
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
PDF
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
PDF
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
PDF
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
PPTX
Online algorithms in Machine Learning
PPTX
NP completeness
PPTX
Algorithmic Puzzles
PPTX
Divide and Conquer - Part 1
PPTX
Set Operations - Union Find and Bloom Filters
PPTX
Binomial Heaps and Fibonacci Heaps
PPTX
R-Trees and Geospatial Data Structures
PPTX
Tries - Tree Based Structures for Strings
PPTX
Splay Trees and Self Organizing Data Structures
PPTX
BTrees - Great alternative to Red Black, AVL and other BSTs
PPTX
Binary Search Trees - AVL and Red Black
PPTX
Graphs, Trees, Paths and Their Representations
PPTX
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
PPTX
Online Algorithms - An Introduction
PPTX
Learning to learn
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Online algorithms in Machine Learning
NP completeness
Algorithmic Puzzles
Divide and Conquer - Part 1
Set Operations - Union Find and Bloom Filters
Binomial Heaps and Fibonacci Heaps
R-Trees and Geospatial Data Structures
Tries - Tree Based Structures for Strings
Splay Trees and Self Organizing Data Structures
BTrees - Great alternative to Red Black, AVL and other BSTs
Binary Search Trees - AVL and Red Black
Graphs, Trees, Paths and Their Representations
Stacks, Queues, Binary Search Trees - Lecture 1 - Advanced Data Structures
Online Algorithms - An Introduction
Learning to learn

Recently uploaded (20)

PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharma ospi slides which help in ospi learning
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
VCE English Exam - Section C Student Revision Booklet
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharma ospi slides which help in ospi learning
Anesthesia in Laparoscopic Surgery in India
202450812 BayCHI UCSC-SV 20250812 v17.pptx
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chinmaya Tiranga quiz Grand Finale.pdf
Classroom Observation Tools for Teachers
master seminar digital applications in india
human mycosis Human fungal infections are called human mycosis..pptx
GDM (1) (1).pptx small presentation for students
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Microbial diseases, their pathogenesis and prophylaxis

Graph Traversal Algorithms - Breadth First Search

  • 1. Analysis and Design of Algorithms BREADTH FIRST SEARCH, BRANCHING AND BOUNDING
  • 2.  Instructor Prof. Amrinder Arora [email protected] Please copy TA on emails Please feel free to call as well   Available for study sessions Science and Engineering Hall GWU Algorithms Graph Traversal Techniques, Branch & Bound 2 LOGISTICS
  • 3. Algorithms Analysis Asymptotic NP- Completeness Design D&C Greedy DP Graph B&B Applications Algorithms Graph Traversal Techniques, Branch & Bound 3 WHERE WE ARE  Done  Done  DFS, BFS  Done  Done
  • 4. Knowing that an object exists within a certain distance from us, in an infinite maze, how can we find it? Algorithms Graph Traversal Techniques, Branch & Bound 4 INFINITE MAZE
  • 5. 1. Select an unvisited node s, visit it, have it be the root in a BFS tree being formed. Its level is called the current level. 2. From each node x in the current level, in the 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. 3. Repeat the previous step until no more nodes can be visited. 4. If there are still unvisited nodes, repeat from Step 1. Algorithms Graph Traversal Techniques, Branch & Bound 5 BREADTH FIRST SEARCH (BFS)
  • 7.  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. Algorithms Graph Traversal Techniques, Branch & Bound 7 BFS IMPLEMENTATION
  • 8. 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) Algorithms Graph Traversal Techniques, Branch & Bound 8 BFS PSEUDOCODE
  • 9.  Robotics  Optimization problems using Branch and Bound Algorithms Graph Traversal Techniques, Branch & Bound 9 BFS APPLICATIONS
  • 10.  Hamiltonian Cycle  K-clique  K-coloring Algorithms Graph Traversal Techniques, Branch & Bound 10 OTHER GRAPH PROBLEMS
  • 11. Algorithms Analysis Asymptotic NP- Completeness Design D&C Greedy DP Graph B&B Applications Algorithms Graph Traversal Techniques, Branch & Bound 11 WHERE WE ARE  Done  Done  Starting today..  Done  Done  Done
  • 12.  A systematic method for solving optimization problems  A general optimization technique that applies where the greedy method and dynamic programming fail.  Much slower – often leads to exponential time complexities in the worst case. If applied carefully, can lead to algorithms that run reasonably fast on average.  General idea of B&B is a BFS-like search for the optimal solution, but not all nodes get expanded.  Carefully selected criterion determines which node to expand and when  Another criterion tells the algorithm when an optimal solution has been found. Algorithms Graph Traversal Techniques, Branch & Bound 12 BRANCH AND BOUND
  • 13.  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? Algorithms Graph Traversal Techniques, Branch & Bound 13 B&B FOR JOB ASSIGNMENT J1 J2 J3 J4 J5 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
  • 14. What is the lower bound? [In other words, how much will it cost at minimum to do the job assignment?] 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”. Algorithms Graph Traversal Techniques, Branch & Bound 14 LOWER BOUND
  • 15.  Any random assignment can be an upper bound  Or, we can use a greedy algorithm for upper bound.  In the context of a minimization problem, upper bound means: “Here is a solution that I have already found. We are not interested in solutions that are more expensive than this.” So, in other words, this solution now defines the highest cost (the upper bound on cost) that we are willing to pay.  If we find an even better solution, then we will decrease our upper bound. Algorithms Graph Traversal Techniques, Branch & Bound 15 UPPER BOUND
  • 16.  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) Algorithms Graph Traversal Techniques, Branch & Bound 16 BRANCHING
  • 17.  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 Algorithms Graph Traversal Techniques, Branch & Bound 17 MORE.. (FROM WIKIPEDIA)
  • 18.  We can consider a maximization problem just as easily in B&B as well.  In case of a maximization problem, the “lower bound” comes from a known solution. The “upper bound” comes from a theoretical/analytical solution that typically relaxes some constraint.  Lower bound signifies: A solution we already know exists  Upper bound signifies: Maximum value we could obtain, even if some constraints were relaxed.  An example of a maximization problem is a 0/1 knapsack problem. Algorithms Graph Traversal Techniques, Branch & Bound 18 B&B FOR MAXIMIZATION PROBLEMS
  • 19.  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. Algorithms Graph Traversal Techniques, Branch & Bound 19 0/1 KNAPSACK PROBLEM
  • 20.  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 = $160  Optimal solution: Item 3 + Item 2, worth = $220 Algorithms Graph Traversal Techniques, Branch & Bound 20 0/1 KNAPSACK EXAMPLE
  • 21.  Given a complete graph with n vertices, the salesperson wishes to make a tour, visiting each city exactly once and finishing at the city he starts from. Cost of going from city i to city j = c(i,j). Algorithms Graph Traversal Techniques, Branch & Bound 21 TRAVELING SALESPERSON PROBLEM (TSP)
  • 22.  Input: n jobs, n employees, and an n x n matrix A where Aij be the cost if person i performs job j.  Problem: Find a one-to-one matching of the n employees to the n jobs so that the total cost is minimized.  Formally, find a permutation f such that C(f), where C(f)=A1f(1) + A2f(2) + ... + Anf(n) is minimized. Algorithms Graph Traversal Techniques, Branch & Bound 22 JOB ASSIGNMENT PROBLEM
  • 23.  Do a Breadth First Search  Evaluate each node for upper and lower bounds  Branch into the “best” node  Terminate if solution meets performance parameters Algorithms Graph Traversal Techniques, Branch & Bound 23 BRANCH AND BOUND TEMPLATE
  • 24.  Branch and Bound depends upon being able to “bound” each node in the search tree, so that we can evaluate whether or not to expand it.  Lower bound and upper bound depend on the problem Algorithms Graph Traversal Techniques, Branch & Bound 24 BRANCH AND BOUND TEMPLATE (CONT.)
  • 25.  Using a mixture of upper and lower bounds, we can find when might be a right time to terminate the search. Algorithms Graph Traversal Techniques, Branch & Bound 25 TERMINATION CRITERIA
  • 26.  B&B is an interesting technique that uses BFS and bounding to eliminate the nodes in the search tree.  Can solve problems that are intrinsically harder.  Time complexity may not be polynomial, but may be practical.  We can return an approximate, usable solution with some bound on performance.  Developing interesting bounds depends upon the problem and uses problem specific insights. Algorithms Graph Traversal Techniques, Branch & Bound 26 SUMMARY
  • 27. Algorithms Analysis Asymptotic NP- Completeness Design D&C Greedy DP Graph B&B Applications Algorithms Graph Traversal Techniques, Branch & Bound 27 WHERE WE ARE  Done  Done  Done  Done  Done  Done
  • 28.  Job Assignment problem, Branch and Bound  Review slides again – Be ready to discuss lower bound and upper bounds  http://en.wikipedia.org/wiki/Branch_and_bound  “An Automatic Method of Solving Discrete Programming Problems”  http://rjlipton.wordpress.com/2012/12/19/branch- and-bound-why-does-it-work/  Preview: NP completeness and lower bound for coins problem. Algorithms Graph Traversal Techniques, Branch & Bound 28 READING ASSIGNMENT/PREVIEW