Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Backtracking and Branch and Bound Algorithms: Solving Constrained Sequence Problems, Study notes of Digital & Analog Electronics

The backtracking and branch and bound algorithms used to solve problems where a sequence of objects must be selected from a set while satisfying certain constraints. The backtracking algorithm performs a depth-first traversal of a tree, pruning entire sub-trees if their root nodes are not viable solutions. The branch and bound algorithm, on the other hand, uses a breadth-first search with pruning and a priority queue as an auxiliary data structure. Both algorithms are illustrated with examples, including the n-queens problem and the traveling salesman problem.

Typology: Study notes

2010/2011

Uploaded on 09/02/2011

hamit1990
hamit1990 🇮🇳

4.3

(68)

97 documents

1 / 22

Toggle sidebar

Related documents


Partial preview of the text

Download Backtracking and Branch and Bound Algorithms: Solving Constrained Sequence Problems and more Study notes Digital & Analog Electronics in PDF only on Docsity! Backtracking & Branch and Bound Backtracking Algorithm • Is used to solve problems for which a sequence of objects is to be selected from a set such that the sequence satisfies some constraint • Traverses the state space using a depth-first search with pruning • One option would be to generate a tree of every possible board layout • This would be an expensive way to find a solution Backtracking • Backtracking prunes entire sub trees if their root node is not a viable solution • The algorithm will “backtrack” up the tree to search for other possible solutions Backtracking 8 queens problem Basic idea of solution: 1. Start with one queen in the first column, first row. 2. Start with another queen in the second column, first row. 3. Go down with the second queen until you reach a permissible situation. Backtracking 8 queens problem A slow example: gia} fal | [fa Qllq | lle Q Q Q Q Q illegal illegal legal ill legal illegal il I cannot go further down in row 3. I must backtrack! egal Backtracking 8 queens problem Q However. I cannot go further down in column 2? either. I must backtrack one more step. Backtracking 8 queens problem Now I start again in the second column. Branch and Bound • Where backtracking uses a depth- first search with pruning, the branch and bound algorithm uses a breadth- first search with pruning • Branch and bound uses a queue as an auxiliary data structure The Branch and Bound Algorithm • Starting by considering the root node and applying a lower-bounding and upper-bounding procedure to it • If the bounds match, then an optimal solution has been found and the algorithm is finished • If they do not match, then algorithm runs on the child nodes Example: The Traveling Salesman Problem Branch and bound can be used to solve the TSP using a priority queue as an auxiliary data structure An example is the problem with a directed graph given by this adjacency matrix: Traveling Salesman Problem • The node is added to the priority queue • The node with the lowest bound is then removed • This calculation for the bound for the node of the partial tours is repeated on this node • The process ends when the priority queue is empty Traveling Salesman Problem • The final results of this example are in this tree: • The accompanying number for each node is the order it was removed in Efficiency of Branch and Bound • In many types of problems, branch and bound is faster than branching, due to the use of a breadth-first search instead of a depth-first search • The worst case scenario is the same, as it will still visit every node in the tree
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved