Backtracking: Backtracking is an algorithmic-technique for solving problems recursively by trying to build a solution incrementally, one piece at a time, removing those solutions that fail to satisfy...

1 answer below »
Please discuss backtracking and branch and bound algorithm design techniques for solving problems with an example


Backtracking: Backtracking is an algorithmic-technique for solving problems recursively by trying to build a solution incrementally, one piece at a time, removing those solutions that fail to satisfy the constraints of the problem at any point of time. In other words, Backtracking can be defined as a general algorithmic technique that considers searching every possible combination in order to solve a computational problem. There are three types of problems in backtracking – 1. Decision Problem – In this, we search for a feasible solution. 2. Optimization Problem – In this, we search for the best solution. 3. Enumeration Problem – In this, we find all feasible solutions. Example: (Eight Queens Problem) The eight queens puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an example of the more general n-queens problem of placing n non-attacking queens on an n×n chessboard, for which solutions exist for all natural numbers n with the exception of n = 2 and n = 3. The idea is to place queens one by one in different columns, starting from the leftmost column. When we place a queen in a column, we check for clashes with already placed queens. In the current column, if we find a row for which there is no clash, we mark this row and column as part of the solution. If we do not find such a row due to clashes then we backtrack and return false. 1) Start in the leftmost column2) If all queens are placed return true3) Try all rows in the current column. Do following for every tried row. a) If the queen can be placed safely in this row then mark this [row, column] as part of the solution and recursively check if placing queen here leads to a solution. b) If placing the queen in [row, column] leads to a solution then return true. c) If placing queen doesn't lead to a solution then unmark this [row, column] (Backtrack) and go to step (a) to try other rows.4) If all rows have been tried and nothing worked, return false to trigger backtracking. Branch and Bound Algorithm Branch and bound is an algorithm design paradigm for discrete and combinatorial optimization problems, as well as mathematical optimization. A branch-and-bound algorithm consists of a systematic enumeration of candidate solutions by means of state space search: the set of candidate solutions is thought of as forming a rooted tree with the full set at the root. The algorithm explores branches of this tree, which represent subsets of the solution set. Before enumerating the candidate solutions of a branch, the branch is checked against upper and lower estimated bounds on the optimal solution, and is discarded if it cannot produce a better solution than the best one found so far by the algorithm. The algorithm depends on efficient estimation of the lower and upper bounds of regions/branches of the search space. If no bounds are available, the algorithm degenerates to an exhaustive search. Example: (0/1 Knapsack Problem) The branch and bound based solution works better for 0/1 Knapsack Problem than brute force by ignoring infeasible solutions. We can do better (than backtracking) if we know a bound on best possible solution subtree rooted with every node. If the best in subtree is worse than current best, we can simply ignore this node and its subtrees. So we compute bound (best solution) for every node and compare the bound with current best solution before exploring the node. Branch and bound is very useful technique for searching a solution but in worst case, we need to fully calculate the entire tree. At best, we only need to fully calculate one path through the tree and prune the rest of it.
Answered Same DayApr 18, 2021

Answer To: Backtracking: Backtracking is an algorithmic-technique for solving problems recursively by trying to...

Ritika answered on Apr 19 2021
133 Votes
Branch and Bound
The N Queens are placed on a chess board and threaten each other on a NxN chessboard. The solut
ion requires that 2 queens share the same row, column or diagonal.
Backtracking
When we hit a dead end, we backtrack. In Branch and Bound solution, we build a partial solution, and when we realize that there is no point in going any deeper as we will hit a dead end, we stop.
Solution: The aim is to place queens in different columns one by one. We begin with the leftmost column. When a queen is placed in a column, we check if there are any clashes amongst the queens that have already been placed.
In the current column, we find and mark a row with no clash as a part of the solution. If we are unable to find a row because of clashes, then we backtrack and return false.”
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
For the 1st Queen, there are total 8 possibilities. We can place 1st Queen in any row of first column. We will place the 1st Queen 1 on row...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here