SlideShare a Scribd company logo
1 of 16
Backtracking And Branch And Bound
Subset & Permutation Problems
• Subset problem of size n.
 Nonsystematic search of the space for the answer takes
O(p2n) time, where p is the time needed to evaluate
each member of the solution space.
• Permutation problem of size n.
 Nonsystematic search of the space for the answer takes
O(pn!) time, where p is the time needed to evaluate
each member of the solution space.
• Backtracking and branch and bound perform a
systematic search; often taking much less time
than taken by a nonsystematic search.
Tree Organization Of Solution Space
• Set up a tree structure such that the leaves
represent members of the solution space.
• For a size n subset problem, this tree structure has
2n leaves.
• For a size n permutation problem, this tree
structure has n! leaves.
• The tree structure is too big to store in memory; it
also takes too much time to create the tree
structure.
• Portions of the tree structure are created by the
backtracking and branch and bound algorithms as
needed.
Subset Tree For n = 4
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
x3=1 x3= 0
x4=1 x4=0
1110 1011 0111 0001
Permutation Tree For n = 3
x1=1 x1=2
x1= 3
x2= 2 x2= 3 x2= 1 x2= 3 x2= 1 x2= 2
x3=3 x3=2 x3=3 x3=1 x3=2 x3=1
123 132 213 231 312 321
Backtracking
• Search the solution space tree in a depth-
first manner.
• May be done recursively or use a stack to
retain the path from the root to the current
node in the tree.
• The solution space tree exists only in your
mind, not in the computer.
Backtracking Depth-First Search
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
Backtracking Depth-First Search
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
Backtracking Depth-First Search
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
Backtracking Depth-First Search
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
Backtracking Depth-First Search
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
O(2n) Subet Sum & Bounding Functions
x1=1 x1= 0
x2=1 x2= 0 x2=1 x2= 0
Each forward and backward move takes O(1) time.
{10, 5, 2, 1}, c = 14
Backtracking
• Space required is O(tree height).
• With effective bounding functions, large instances
can often be solved.
• For some problems (e.g., 0/1 knapsack), the
answer (or a very good solution) may be found
quickly but a lot of additional time is needed to
complete the search of the tree.
• Run backtracking for as much time as is feasible
and use best solution found up to that time.
Branch And Bound
• Search the tree using a breadth-first search (FIFO
branch and bound).
• Search the tree as in a bfs, but replace the FIFO
queue with a stack (LIFO branch and bound).
• Replace the FIFO queue with a priority queue
(least-cost (or max priority) branch and bound).
The priority of a node p in the queue is based on
an estimate of the likelihood that the answer node
is in the subtree whose root is p.
Branch And Bound
• Space required is O(number of leaves).
• For some problems, solutions are at different
levels of the tree (e.g., 16 puzzle).
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15
1
3
2
4
5
6
13
14
15
12
11 10
9 7
8
Branch And Bound
 FIFO branch and bound finds solution closest to root.
 Backtracking may never find a solution because tree
depth is infinite (unless repeating configurations are
eliminated).
• Least-cost branch and bound directs the search to
parts of the space most likely to contain the
answer. So it could perform better than
backtracking.

More Related Content

Similar to branch bb.ppt

4a searching-more
4a searching-more4a searching-more
4a searching-moreShahzad Ali
 
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.Wuhyun Rico Shin
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Kumar
 
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbPAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbratnapatil14
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AIKirti Verma
 
Erik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better MortgageErik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better MortgageMLconf
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxarifimad15
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.pptzalanmvb
 
Recursive Neural Networks
Recursive Neural NetworksRecursive Neural Networks
Recursive Neural NetworksSangwoo Mo
 
Recursion and Sorting Algorithms
Recursion and Sorting AlgorithmsRecursion and Sorting Algorithms
Recursion and Sorting AlgorithmsAfaq Mansoor Khan
 
Branch and bound
Branch and boundBranch and bound
Branch and boundAcad
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12AnusAhmad
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFSKuppusamy P
 

Similar to branch bb.ppt (20)

Treesandgraphs
TreesandgraphsTreesandgraphs
Treesandgraphs
 
14 query processing-sorting
14 query processing-sorting14 query processing-sorting
14 query processing-sorting
 
Search strategies
Search strategiesSearch strategies
Search strategies
 
4a searching-more
4a searching-more4a searching-more
4a searching-more
 
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.
Paper review: Measuring the Intrinsic Dimension of Objective Landscapes.
 
Back tracking and branch and bound class 20
Back tracking and branch and bound class 20Back tracking and branch and bound class 20
Back tracking and branch and bound class 20
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbPAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
 
Erik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better MortgageErik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better Mortgage
 
03 search blind
03 search blind03 search blind
03 search blind
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
 
Splay tree
Splay treeSplay tree
Splay tree
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.ppt
 
2.uninformed search
2.uninformed search2.uninformed search
2.uninformed search
 
Recursive Neural Networks
Recursive Neural NetworksRecursive Neural Networks
Recursive Neural Networks
 
Recursion and Sorting Algorithms
Recursion and Sorting AlgorithmsRecursion and Sorting Algorithms
Recursion and Sorting Algorithms
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFS
 

Recently uploaded

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf203318pmpc
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 

Recently uploaded (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 

branch bb.ppt

  • 2. Subset & Permutation Problems • Subset problem of size n.  Nonsystematic search of the space for the answer takes O(p2n) time, where p is the time needed to evaluate each member of the solution space. • Permutation problem of size n.  Nonsystematic search of the space for the answer takes O(pn!) time, where p is the time needed to evaluate each member of the solution space. • Backtracking and branch and bound perform a systematic search; often taking much less time than taken by a nonsystematic search.
  • 3. Tree Organization Of Solution Space • Set up a tree structure such that the leaves represent members of the solution space. • For a size n subset problem, this tree structure has 2n leaves. • For a size n permutation problem, this tree structure has n! leaves. • The tree structure is too big to store in memory; it also takes too much time to create the tree structure. • Portions of the tree structure are created by the backtracking and branch and bound algorithms as needed.
  • 4. Subset Tree For n = 4 x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0 x3=1 x3= 0 x4=1 x4=0 1110 1011 0111 0001
  • 5. Permutation Tree For n = 3 x1=1 x1=2 x1= 3 x2= 2 x2= 3 x2= 1 x2= 3 x2= 1 x2= 2 x3=3 x3=2 x3=3 x3=1 x3=2 x3=1 123 132 213 231 312 321
  • 6. Backtracking • Search the solution space tree in a depth- first manner. • May be done recursively or use a stack to retain the path from the root to the current node in the tree. • The solution space tree exists only in your mind, not in the computer.
  • 7. Backtracking Depth-First Search x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0
  • 8. Backtracking Depth-First Search x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0
  • 9. Backtracking Depth-First Search x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0
  • 10. Backtracking Depth-First Search x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0
  • 11. Backtracking Depth-First Search x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0
  • 12. O(2n) Subet Sum & Bounding Functions x1=1 x1= 0 x2=1 x2= 0 x2=1 x2= 0 Each forward and backward move takes O(1) time. {10, 5, 2, 1}, c = 14
  • 13. Backtracking • Space required is O(tree height). • With effective bounding functions, large instances can often be solved. • For some problems (e.g., 0/1 knapsack), the answer (or a very good solution) may be found quickly but a lot of additional time is needed to complete the search of the tree. • Run backtracking for as much time as is feasible and use best solution found up to that time.
  • 14. Branch And Bound • Search the tree using a breadth-first search (FIFO branch and bound). • Search the tree as in a bfs, but replace the FIFO queue with a stack (LIFO branch and bound). • Replace the FIFO queue with a priority queue (least-cost (or max priority) branch and bound). The priority of a node p in the queue is based on an estimate of the likelihood that the answer node is in the subtree whose root is p.
  • 15. Branch And Bound • Space required is O(number of leaves). • For some problems, solutions are at different levels of the tree (e.g., 16 puzzle). 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 3 2 4 5 6 13 14 15 12 11 10 9 7 8
  • 16. Branch And Bound  FIFO branch and bound finds solution closest to root.  Backtracking may never find a solution because tree depth is infinite (unless repeating configurations are eliminated). • Least-cost branch and bound directs the search to parts of the space most likely to contain the answer. So it could perform better than backtracking.