You are on page 1of 3

Branch and Bound

E-node is the node that is being explored currently.


Exploring a node means generating all its children (branches or live-nodes).
In Branch and Bound Technique, all branches(live nodes) of an E-node are generated, before
one of the branches(live node) becomes an E-node
There are three types of Branch and Bound techniques. They are:
1. LCBB 2.LIFOBB 3.FIFOBB
Applying Branch and Bound Technique to 0/1 knapsack problem:
Branch and Bound technique is designed for minimization problem.
But, 0/1 knapsack problem is a maximization problem(as we have to maximize profit). So,
we have to multiply bounds(lower and upper) with -1.
Do not consider fractions while computing upper bound(UB)
Consider fractions while computing lower bound(LB)
LCBB(Least Cost Branch and Bound):
The live node with minimum(UB-LB) value becomes E-node in the next iteration.
If two live nodes have same (UB-LB) value, then the node with least UB value becomes Enode in the next iteration.
LIFOBB(Last In First Out Branch and Bound):
Let, LUB= Least Upper Bound, CUB = Current Upper Bound, & CLB = Current Lower
Bound,
Initialize LUB to infinity.
If (CUB<LUB) then LUB=CUB
If(CLB>LUB) then kill that node
Use Stack to hold all live nodes of E-node.
FIFOBB(First in First Out Branch and Bound): This is same as LIFOBB, except
that, here, we use Queue instead of Stack to hold all live nodes of E-node.

Quick Sort
Bestcase
example:
[3 1 2 5 4]
[1 2] 3 [4 5]
1 [2]
4
[5]
-----------------------1
2 3 4 5

Worst Case
[1 2 3 4 5]
1 [5 4 3 2]
[4 3 2] 5
[ 3 2] 4
[ 2] 3
--------------------1
2 3 4 5

Dynamic Programming: Dynamic programming obtains solution by using principle


of optimality. Principle of optimality states that, In an optimal sequence of
decisions (choices), each sub-sequence must also be optimal. Ie. If A-B-C-D is
optimal sequence, then the sequences A-B-C, B-C-D, A-B, B-C, C-D are also optimal.
OBST:

NOTE: Cost of a tree = Cost of its Left Sub Tree + Cost of its Right Sub Tree + Sum
of all probabilities in that tree. ie. Cost of t(0,3) = Cost of t(0,1) + Cost of t(2,3) +
w(0,3)
Similarly,
Cost of t(0,1)=Cost of t(0,0) + Cost of t(1,1) + w(0,1)

w(0,3)= sum of all probabilities in t(0,3) =p1+p2+p3+q0+q1+q2+q3


w(0,1)=sum of all probabilities in t(0,1)=p1+q0+q1
c(0,3)= cost of tree t(0,3)
c(0,1)= cost of tree t(0,1)

OBST = Optimal Binary Search Trees


MCM=Matrix Chain Multiplication

Basic Searching and Traversing:


All trees are graphs, but all graphs are not trees. A graph is not a tree if it contains
cycle.
Visiting some or all nodes based on some condition is called searching. Searching is
applicable for graphs.
Visiting all nodes without bothering about any condition is called traversal.
Traversal is applicable for trees.
In BFS, a node is fully explored before starting exploration of other node.
In DFS, the exploration of a node Is suspended as soon as a new unexplored node is
reached. The exploration of a new node is immediately begun.

You might also like