Backtracking Branch Bound
Backtracking Branch Bound
If FEASIBLE_SUB_SET(i) == 1
{ If (sum == W) then print X[1…i] end }
Else
{ X[i + 1] ← 1
SUB_SET_PROBLEM(i + 1, sum + w[i] + 1, W, remSum – w[i] + 1 )
X[i + 1] ← 0 // Exclude the ith item
SUB_SET_PROBLEM(i + 1, sum, W, remSum – w[i] + 1 ) end
Function FEASIBLE_SUB_SET(i)
If (sum + remSum ≥ W) AND (sum == W) or (sum + w[i] + 1 ≤ W) then
return 0
End
return 1
DEPARTMENT OF COMPUTER ENGINEERING, Sanjivani COE, Kopargaon 20
Complexity Analysis
• To derive the complexity of sum of the subset problem, In the state-
space tree, at level i, the tree has 2i nodes.
• So, given n items, the total number of nodes in the tree would be 1 + 2
+ 22 + 23 + .. 2n.
• T(n) = 1 + 2 + 22 + 23 + .. 2n = 2n+1 – 1 = O(2n)
• Thus, sum of sub set problem runs in exponential order.
• we will calculate lower bound and upper bound for each node in State Space
Tree (SPT).
• Knapsack problem is maximization problem, but branch and bound technique
is applicable for only minimization problems. In order to convert
maximization problem into minimization problem we have to take negative
sign for upper bound and lower bound.
• We choose the path in SPT, which has minimum difference of upper bound
and lower bound. If the difference is equal then we choose the path by
comparing upper bounds and we discard node with maximum upper bound.
• fractions are allowed in calculation of lower bound.(L)
• No fractions are allowed in calculation of upper bound(u)
Solution PPT