# What is Difference between backtracking and branch and bound method?

Backtracking [1] It is used to find all possible solutions available to the problem. [2] It traverse tree by DFS(Depth First Search). [3] It realizes that it has made a bad choice & undoes the last choice by backing up. [4] It search the state space tree until it found a solution. [5] It involves feasibility function. Branch-and-Bound (BB) [1] It is used to solve optimization problem. [2] It may traverse the tree in any manner, DFS or BFS. [3] It realizes that it already has a better optimal solution that the pre-solution leads to so it abandons that pre-solution. [4] It completely searches the state space tree to get optimal solution. [5] It involves bounding function. The difference between branch-&-bound and backtracking is used for optimization problem does not limit us to a particular way of traversing the tree We compute a number at a node to determine whether the node is promising. If that bound is no better than the value of the best solution found so far, the node is nonpromising. breadth-first search (queue) Algorithm in page 224 Figure 6.1 best-first search (priority queue)：we can compare the bounds of promising nodes and visit the children of the one with the best bound. best-first search with branch-&-bound pruning breadth-first search with branch-&-bound pruning

NIT 4 : Backtracking and Branch and Bound Backtracking – N Queen’s problem – Hamiltonian circuit problem – Subset sum problem – Branch and Bound – Assignment problem – Knapsack problem – Traveling salesman problem. Two marks: 1. What are the state space algorithms? Backtracking and Branch-and-bound are called state-space algorithms as they generate state-space tree while solving the problem. 2. What are the differences between exhaustive search method and state-space algorithms? State-space algorithms make it possible to solve some larger instances of difficult combinatorial problems. Unlike exhaustive search, state-space algorithms generate candidate solutions one component at a time and evaluate the partially constructed solutions. If no potential values of the remaining components can lead to a solution, the remaining components are not generated at all. 3. What are the differences between backtracking and branch-and-bound methods?

sn}of n positive integers. and evaluate such partially constructed candidates as: ¨ If a partially constructed solution can be developed further without violating the problem’s constraints. Its root represents initial state before the search for a solution and the nodes at each level represent the choices made for the corresponding component of a solution. Backtracking is more often not applied to non-optimization. What is promising and non-promising node? A node in state-space tree is said to be promising. Backtracking generates tree by depth-first rule. //Output : All the tuples representing the problems solutions. Define Backtracking.. 5. //Input : X[1. A subset sum problem finds a subset of a given set S={s1. such that no two queens attack each other by being in the same row or in the same column or on the same diagonal. 4. What is a subset sum problem? Find the subset from the set S={1.i] specifies first I promising components of a solution. {3. that node is non-promising.i]) //Gives a template of a generic backtracking algorithm.(i) Branch-and-Bound algorithms can be applied only to optimization problems.3. (ii) Branch-and-bound generates nodes by Best-first rule.. N-Queen’s problem is to place n-queens on an n x n chessboard.s2. What is N-Queen’s problem? Give any one solution to 6-Queen’s problem..i] is a solution write X[1.i]
. If X[1. for the sum d=7 using backtracking. Draw the backtracking tree to find the subset. 7. 9. What is a state-space tree? The tree construted to implement backtracking with the choices for the components is called the statespace tree. taking the first remaining legitimate option for the next component does it. What is a Hamiltonian circuit? A Hamiltonian circuit in a graph is the path that starts and ends at the same vertex and passes through all the other vertices exactly once.4}. In this case...2. 10. whose sum is equal to a given positive integer d. Backtracking is the technique that constructs one component at a time.4}.4}. no alternatives for any remaining component need to be considered. ¨ If there is no legitimate option for the next component. Result: {1.2. Algorithm Backtrack(X[1. the algorithm backtracks to replace the last component of the partially constructed solution with its next option. Write the general algorithm for backtracking. Otherwise. One of the solutions to 6-Queen’s problem is Q Q Q Q Q Q 8. 6. if it corresponds to a partially constructed solution that may still lead to complete solution..

the steps are: · Order the items given in descending order. What is a feasible solution and optimal solution? A feasible solution is a point in the problem’s state-space that satisfies all the problem’s constraints. otherwise exclusion of the item. it computes the lower bound. 16 Marks: 1. It considers the lower bound for minimization problem and the upper bound for maximization problem. That is.Compute sum S of these n numbers. · The node represents no feasible solutions. What is Assignment problem? The Assignment problem assign n people to n jobs.w2. one person per job.i] and the constraints do X[i+1] ß x Backtrack (X[1. What are the reasons for terminating search path at current node in the state-space tree? · The value of the nodes bound is not better than the value of the best solution seen so far. because the constraints of the problem are already violated. 12. The state-space tree provides the nodes which are bound on the best value of the objective function on any solution. so that the total cost of the assignment is as small as possible. 16. · To solve branch-and-bound problem.wn and the values are v1. Travelling salesman problem as it finds the shortest tour. that can be obtained by adding further components to the partial solution represented by the node. Divide S by 2 to find lower bound. Hints : Refer Question two marks 3 – Minimization problem – Maximization problem – Steps for Branch and bound – Steps for Backtracking. Set a constraint such that any city should be visited before another. To compute lower bound. Find the most valuable subset of items.
.vn. What is travelling salesman problem? How it could be solved using branch-and-bound technique? The travelling salesman problem is to find the shortest tour through a given set of n cities that visits each city exactly once before returning to the city where it started.else for each element x ε Si+1 consistent with X[1. The capacity of Knapsack is W. with the best value of the objective function. Find the sum Si of the distances from city i to the nearest cities. Explain Branch-and-bound method. 15. that fit into knapsack. Find the assignment with the smallest total cost. State the difference between branch and bound and backtracking. The cost of assigning ith person to jth job is C[i.. (6).i+1]) 11. 13. This reduces more work in generating all-pairs of permutations. by their value-to-weight ratios. An optimal solution is a feasible solution. The branch-and-bound method uses the state-space tree. 14. · Construct the state-space tree as binary tree..j]. if the new solution is better. And write about minimization and maximization problems. The non-promising nodes will be terminated if no solution obtained from it can yield better solution than the one already available.. Each node on ith level indicate inclusion of item to the set.v2. there are n people who need to be assigned to execute n jobs.. The result is the value of the best solution obtained so far. What is Knapsack problem? How it could be solved by branch-and-bound problems? There are n items of known weights w1. · The subset of feasible solutions represented by the node consists of a single point – here we compare the value of the objective function for this feasible solution with that of the best solution seen so far and update the latter with the former. if the node is left child.

assign job to 4 persons. 3. solve the knapsack problem. 13}. Job1 Job2 Job3 Job4 7 3 2 6 Person1 5 2 6 8 Person2 2 5 1 4 Person3 4 6 2 3 Person4 Hints : Problem description for Job assignment problem – Write about branch and bound problem – Explain the steps for solving minimization problem – Draw state-space tree – Conclusion.Queen’s problem and Write the steps for solving it using backtracking. If there is a Knapsack of capacity W= 6 and the weights and values of the items are mentioned as below. with branch and bound technique. ABCDEF A010010 B101010 C010111 D001010 E111101 F001010 Hints : Explain Hamiltonian circuit – Draw the Graph from the adjacency matrix. 5. 9. 3. For the given subset S= { 1.2. Hints: Problem description of n-queen’s problem – Write about backtracking – General algorithm of backtracking -Draw state space tree of 8-Queen’s problem till any two solutions is found – Explain the steps done to find the solution. whose sum will be equivalent to d= 13. 7. Find the Hamiltonian circuit for the graph corresponding to the following adjacency matrix and explain about the steps in detail. Item no Weight Value 1 4 $40 2 3 $12 3 1 $15 4 2 $40
.General algorithm of backtracking -Draw backtracking tree – Explain the steps – Write the conclusion. 4. Hints : Problem description for subset-sum problem – Write about backtracking – General algorithm of backtracking . 6.Draw the subset sum tree using backtracking – Explain the steps – Conclusion. For the following cost matrix. Write any two solutions for 8. find the subsets.Write about backtracking.