Unit 5 - Analysis and Design of Algorithm
Unit 5 - Analysis and Design of Algorithm
Tech
Subject Name: Analysis and Design of Algorithm
Subject Code: IT-403
Semester: 4th
Downloaded from be.rgpvnotes.in
Introduction:
Branch & Bound (B & B) is general algorithm (or Systematic method) for finding optimal solution
of various optimization problems, especially in discrete and combinatorial optimization.
The B&B strategy is very similar to backtracking in that a state space tree is used to solve a
problem.
The differences are that the B&B method
Does not limit us to any particular way of traversing the tree.
It is used only for optimization problem
It is applicable to a wide variety of discrete combinatorial problem.
B&B is rather general optimization technique that applies where the greedy method &
dynamic programming fail.
It is much slower, indeed (truly), it often (rapidly) leads to exponential time complexities in
the worst case.
The te B&B efe s to all state spa e sea h ethods i hi h all hild e of the E- ode
are generated befo e a othe li e ode a e o e the E- ode
Live node is a node that has been generated but whose children have not yet been
generated.
E-node is a live node whose children are currently being explored.
Dead node is a generated node that is not to be expanded or explored any further. All
children of a dead node have already been expanded.
Two graph search strategies, BFS & D-search (DFS) in which the exploration of a new node
cannot begin until the node currently being explored is fully explored.
Both BFS & D-search (DFS) generalized to B&B strategies.
BFS like state space search will be called FIFO (First In First Out) search as the list of live
odes is Fi st-in-first-out list o ueue .
D-search (DFS) Like state space search will be called LIFO (Last In First Out) search as the
list of li e odes is a last-in-first-out list o sta k .
In backtracking, bounding function are used to help avoid the generation of sub-trees that
do not contain an answer node.
We will use 3-types of search strategies in branch and bound
1) FIFO (First In First Out) search
2) LIFO (Last In First Out) search
FIFO B&B:
FIFO Branch & Bound is a BFS.
In this, children of E-Node (or Live nodes) are inserted in a queue.
Implementation of list of live nodes as a queue
Least() Removes the head of the Queue
Add() Adds the node to the end of the Queue
LIFO B&B:
LIFO Brach & Bound is a D-search (or DFS).
In this children of E-node (live nodes) are inserted in a stack
Implementation of List of live nodes as a stack
Least() Removes the top of the stack
ADD() Adds the node to the top of the stack.
Def:- Find a tour of minimum cost starting from a node S going through other nodes only
once and returning to the starting point S.
Time Conmlexity of TSP for Dynamic Programming algorithm is O(n22n)
B&B algorithms for this problem, the worest case complexity will not be any better than O(n22n)
but good bunding functions will enables these B&B algorithms to solve some problem instances
in much less time than required by the dynamic programming alogrithm.
Let G=(V,E) be a directed graph defining an instances of TSP.
Let Cij cost of edge <i, j>
Cij =∞ if <i, j> E
|V|=n total number of vertices.
Assume that every tour starts & ends at vertex 1.
Solution Space S= {1, Π , 1 / Π is a pe utatio of (2, 3. 4. ----n) } then |S|=(n-1)!
The size of S reduced by restricting S
Sothat (1, i1,i2,-----in-1, 1} S iff <ij, ij+1> E. O≤j≤ -1, i0-in=1
“ a e o ga ized i to “tate spa e t ee .
Consider the following Example
State space tree for the travelling salesperson problem with n=4 and i0=i4=1
The above diagram shows tree organization of a complete graph with |V|=4.
Ea h leaf ode L is a solutio ode a d ep ese ts the tou defi ed the path f o the oot
to L.
Column 5: It is reduced.
In summary:
Reduce column # 1: by 11
Reduce column # 1: by 11
To find a function g(n) which is a lower bound on the time that algorithm must take, So if f(n) is the
ti e fo so e algo ith the e a ite f =Ω g he e g is lo e ou d fo f(n)Or we can
say f(n) >= c * g(n) for all n>n 0 Where c & n 0 are constants For many problems it is easy to
calculate the lower bound on n inputs e.g. consider the set of problems to find the maximum of an
ordered set of n integers. Clearly every integer must e e a i ed at least o e. “o Ω is a lo e
ou d fo that. Fo at i ultipli atio e ha e i puts so the lo e ou d a e Ω Fo
a u o de ed set the sea hi g algo ith ill take Ω as the lo e ou d. Fo a o de ed set it
will take Ω log as the lo e ou d. “i ila l all the so ti g algo ith s a ot so t i less the
Ω log ti e so Ω log is the lo e ou d fo so ti g algo ith s.
For all sorting & searching we use decision trees/comparison trees for finding the lower bound.
-Internal nodes represent comparisons
-Leaves represent outcomes
-The running time of the algorithm = the length of the path taken.
-Worst-case running time = height of tree.
ITS USE::: EXAMPLE: Sorting
o Decision tree for sorting 3 elements Sort a1, a2, …, an
Each internal node is labeled i:j for i, j { , ,…, n}.
The left subtree shows subsequent comparisons if ai aj.
The right subtree shows subsequent comparisons if ai aj.
Problems with solution time bound by a Problems with solution times not
polynomial of a small degree. bound by polynomial (simply non
polynomial )
Ex:
has been solved by any polynomial
time algorithm
Ordered Search (O (log n)),
Knapsack O(2n/2)
No one has been able to develop a polynomial time algorithm for any problem in the 2nd group
(i.e., group 2) So, it is compulsory and finding algorithms whose computing times are greater than
polynomial very quickly because such vast amounts of time to execute that even moderate size
problems cannot be solved.
Theory of NP-Completeness:
Show that may of the problems with no polynomial time algorithms are computational time
algorithms are computationally related.
There are two classes of non-polynomial time problems
NP-Hard
NP-Complete
NP Complete Problem: A problem that is NP-Complete can solved in polynomial time if and only if
(iff) all other NP-Complete problems can also be solved in polynomial time.
NP-Hard: Problem can be solved in polynomial time then all NP-Complete problems can be solved
in polynomial time.
All NP-Complete problems are NP-Hard but some NP-Hard problems are not know to be NP-
Complete.
P is the set of all decision problems solvable by deterministic algorithms in polynomial time.
NP is the set of all decision problems solvable by nondeterministic algorithms in polynomial time.
Since deterministic algorithms are just a special case of nondeterministic, by this we concluded
that P ⊆NP
Commonly
believed relationship between P & NP
The ost fa ous u sol a le p o le s i Co pute “ ie e is Whethe P=NP o P≠NP
In considering this problem, s.cook formulated the following question.
If there any single problem in NP, such that if we sho ed it to e i P the that ould i pl that
P=NP.
Cook answered this question with
Theorem: Satisfiability is in P if and only if (iff) P=NP
Notation of Reducibility
Let L1 and L2 be problems, Problem L1 reduces to L2 (written L1 α L2) iff there is a way to solve L1 by
a deterministic polynomial time algorithm using a deterministic algorithm that solves L 2 in
polynomial time
This implies that, if we have a polynomial time algorithm for L 2, Then we can solve L1 in polynomial
time.
He e α is a transitive relation i.e., L1 α L2 and L2 α L3 then L1 α L3
A problem L is NP-Hard if and only if (iff) satisfiability reduces to L ie., Statisfiability α L
A problem L is NP-Complete if and only if (iff) L is NP-Hard and L Є NP