SlideShare a Scribd company logo
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

Treesandgraphs
TreesandgraphsTreesandgraphs
Treesandgraphs
Spencer Moran
 
14 query processing-sorting
14 query processing-sorting14 query processing-sorting
14 query processing-sorting
rameswara reddy venkat
 
Search strategies
Search strategiesSearch strategies
Search strategies
Shiwani Gupta
 
4a searching-more
4a searching-more4a searching-more
4a searching-more
Shahzad 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 20
Kumar
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
ER Punit Jain
 
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbPAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
PAT.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
ratnapatil14
 
Uninformed search /Blind search in AI
Uninformed search /Blind search in AIUninformed search /Blind search in AI
Uninformed search /Blind search in AI
Kirti Verma
 
Erik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better MortgageErik Bernhardsson, CTO, Better Mortgage
Erik Bernhardsson, CTO, Better Mortgage
MLconf
 
03 search blind
03 search blind03 search blind
03 search blind
Nour Zeineddine
 
designanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptxdesignanalysisalgorithm_unit-v-part2.pptx
designanalysisalgorithm_unit-v-part2.pptx
arifimad15
 
Splay tree
Splay treeSplay tree
Splay tree
Rajendran
 
BTrees-fall2010.ppt
BTrees-fall2010.pptBTrees-fall2010.ppt
BTrees-fall2010.ppt
zalanmvb
 
2.uninformed search
2.uninformed search2.uninformed search
2.uninformed search
KONGU ENGINEERING COLLEGE
 
Recursive Neural Networks
Recursive Neural NetworksRecursive Neural Networks
Recursive Neural Networks
Sangwoo Mo
 
Recursion and Sorting Algorithms
Recursion and Sorting AlgorithmsRecursion and Sorting Algorithms
Recursion and Sorting Algorithms
Afaq Mansoor Khan
 
Branch and bound
Branch and boundBranch and bound
Branch and bound
Acad
 
[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12[Www.pkbulk.blogspot.com]dbms12
[Www.pkbulk.blogspot.com]dbms12
AnusAhmad
 
Search strategies BFS, DFS
Search strategies BFS, DFSSearch strategies BFS, DFS
Search strategies BFS, DFS
Kuppusamy 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

CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 

Recently uploaded (20)

CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 

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.