SlideShare a Scribd company logo
1 of 16
Download to read offline
1
Fundamentals of Algorithms
BT0080 Part-2
By Milan K Antony
2
1.Write the steps involved in the general method for Branch and
Bound? Explain?
Branch and Bound strategy is a general algorithm for finding
optimal solutions of various optimization problems, especially in
discrete and combinatorial optimization. It consists of a systematic
enumeration of all candidate solutions, where large subsets of fruitless
candidates are discarded en masse, by using upper and lower
estimated bounds of the quantity being optimized.
In the following, we have n kinds of items, 1 through n. Each kind of
item i has a value vi and a weight wi. We usually assume that all values
and weights are nonnegative. To simplify the representation, we can
also assume that the items are listed in increasing order of weight.
The maximum weight that we can carry in the bag is W.
The most common formulation of the problem is the 0-1 knapsack
problem, which restricts the number xi of copies of each kind of item
to zero or one. Mathematically the 0-1-knapsack problem can be
formulated as:
 maximize
 subject to
The bounded knapsack problem restricts the number xi of copies of
each kind of item to a maximum integer value ci. Mathematically the
bounded knapsack problem can be formulated as:
 maximize
 subject to
The unbounded knapsack problem (UKP) places no upper bound on
the number of copies of each kind of item.
3
Of particular interest is the special case of the problem with these
properties:
 it is a decision problem,
 it is a 0-1 problem,
 for each kind of item, the weight equals the value: wi = vi.
1. Algorithm U Bound(cp, cw, k, m)
2. // cp is the current profit total, cw is the current
3. // weight total; k is the index of the last removed
4. // item; and m is the knapsack size
5. // w[i] and p[i] are respectively the weight and profit
6. // of the ith object
7. {
8. b:=cp; c:=cw;
9. for I:=k+1 to n do
10. {
11. if (c+w[i] m) then
12. {
13. c:c+w[i]; b:=b-p[i];
14. }
15. }
16. return b;
17. }
18.
19.
20.
One early application of knapsack algorithms was in the
construction and scoring of tests in which the test-takers have a
choice as to which questions they answer. On tests with a homogeneous
distribution of point values for each question, it is a fairly simple
process to provide the test-takers with such a choice. For example, if
4
an exam contains 12 questions each worth 10 points, the test-taker
need only answer 10 questions to achieve a maximum possible score of
100 points. However, on tests with a heterogeneous distribution of
point values—that is, when different questions or sections are worth
different amounts of points— it is more difficult to provide choices.
Feuerman and Weiss proposed a system in which students are given a
heterogeneous test with a total of 125 possible points. The students
are asked to answer all of the questions to the best of their abilities.
Of the possible subsets of problems whose total point values add up
to 100, a knapsack algorithm would determine which subset gives each
student the highest possible score
2. Explain the NP hard and the NP complete problems?
The best algorithms for their
solutions have computing times that cluster into two groups. The
first group consists of problems whose solution are bounded by
polynomials of small degree.
The second group is made up to problems whose best-known
algorithms are non-polynomial.
Examples we have seen include the traveling salesperson and the
knapsack problems for which the best algorithms given in this text
have complexities O (n22n) and O (2n/2) respectively.
5
In the quest to develop efficient algorithms, no one has been able
to develop a polynomial time algorithm for any problem in the second
group. This is very important because algorithms whose computing
times are greater then, polynomial very quickly require such vast
amounts of time to execute that even moderate-size problems
cannot be solved.
The theory of NP-completeness, which we present here, does
not provide a method of obtaining polynomial time algorithms for
problems in the second group. Nor does it say that algorithms of
this complexity do not exist.
Instead, what we do is show that many of the problems for which
there are 4 no known polynomial time algorithms are computationally
related. In fact, we establish two classes of problems. These are
given names, NP-hard and
NP-Complete.
A problem that is NP-Complete has the property that it can be
6
solved in polynomial time if and only if all other NP-Complete
problems can also be solved in polynomial time. If an 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 known to be
NP-complete.
Although one can define many distinct problem classes having the
properties stated above for the NP- hard and NP-complete classes,
the classes we study are related to non-deterministic computations.
The relationship of these classes to non deterministic computations
together with
the apparent power of non- determinism lead to the intuitive
conclusion that no NP- complete or NP- hard problem is polynomially
solvable.
3. Briefly explain the concept of trees?
7
A tree is a connected graph without any circuits. The graph in
Fig. , for instance, is a tree. Trees with one, two, three and four
vertices are shown in Fig. . A graph must have at least one vertex,
and therefore so must a tree. Some authors allow the null tree, a
tree without
any vertices. It follows immediately from the definition that a tree
has to be a simple graph, that is, having neither a self-loop nor
parallel edges (because they
both form circuits).
Trees appear in numerous instances. The genealogy of a family is
often represented by means of tree (in fact the term tree comes
from family tree)
A river with its tributaries and subtributaries can be represented by
a tree. The sorting of mail according to zip code and the punched
cards is done according to a tree (called decision tree or sorting
tree).
8
Fig. 9.9 C might represent the flow of mail, all the mail arrives at
some local
office, vertex N.
The most
significant digit
in the zip code
is read at N,
and
the mail is divided into 10 piles N1, N2, ... N9 and N0 on the most
9
significant digit. Each pile is further divided into 10 piles according
to second most significant digit, and so on, till the mail is sub
divided into 105 possible piles, each representing a unique five-digit
zip code.
4. Prove that “A tree with n vertices has (n – 1) edges”?
Step (i): If n = 1, then G contains only one vertex and no
edge. So the number of edges in G is n -1 = 1 - 1 = 0.
Step (ii): Induction hypothesis: The statement is true for all trees
with less
than „n vertices.‟
Step (iii): Let us consider a tree with „n vertices.‟
Let „ek be any edge in T whose end vertices are vi and vj.‟
Since T is a tree, there is no other path between vi and vj.
So by removing ek from T, we get a disconnected graph.
Also, T- ek consists of exactly two components(say T1 and T2).
Since T is a tree, there were no circuits in T and so there were no
10
circuits in
T1 and T2. Therefore, T1 and T2 are also trees.
It is clear that |V(T1)| + |V(T2)| = |V(T)| where V(T) denotes the
set of vertices in T.
Also, |V(T1)| and |V(T2)| are les than n.
Therefore, by the induction hypothesis, we have
|E(T1)| = |V(T1)| - 1 and |E(T2)| = |V(T2)| - 1.
Now |E(T)| - 1 = |E(T1)| + |E(T2)| = |V(T1)| - 1 + |V(T2)| - 1
Thus |E(T)| = |V(T1)| + |V(T2)| - 1 = |V(T)| - 1 = n-1.
5. Prove that “A connected graph G is a Euler graph if and only if
it can be decomposed into circuits”
Suppose graph G can be decomposed into circuits; that is, G is a
union of edge-disjoint circuits. Since the degree of every vertex in
a circuit is two, the degree of every vertex in G is even. Hence, G
is an Euler graph.
Conversely, let G be a Euler graph. Consider a vertex v1. There are
11
atleast two edges incident at v1. Let one of these edges be between
v1 and v2. Since vertex v2 is also of even degree, it must have at
least
another edge, say between v2 and v3. Proceeding in this fashion, we
eventually arrive at a vertex that has previously been traversed, thus
forming a circuit . Let us remove from G. All vertices in the
remaining
graph (not necessarily connected) must also be of even degree.
From the remaining graph remove another circuit in exactly the same
way as we removed from G. Continue this process until n o
edges are left.
Hence the theorem.
6. Show that the Clique problem is an NP-complete problem.
The process of establishing a problem as NP-Complete is a
two step process. The first step, which in most of the cases is quite
12
simple, constitutes of guessing possible solutions of the instances, one
instance at a time, of the problem and then verifying whether the
gue ss actually is a solution or not.
The second step involves designing a polynomial-time algorithm which
reduces instances of an already known NP-Complete problem to
instances of the problem, which is intended to be shown as NP-
Complete. However, to begin with, there is a major hurdle in
execution of the second
step. The above technique of reduc tion can not be applied unless
we already have established atleast one problem as NP-Complete.
Therefore, for the first NP-Complete problem, the NP-Completeness
has to be
established in a different manner.
As mentioned earlier, Stephen Cook (1971) established Satisfiability as
the first NP-Complete problem. The proof was based on explicit
reduction of the language of any non-deterministic, polynomial-time
13
TM to the satisfiability problem.
The proof of satisfiability problem as the first NP-Complete problem,
is quite lengthy and we skip the proof. Interested readers may
consult any of the texts given in the reference.
Assuming the satisfiability problem as NP-Complete, the rest of the
problems that we establish as NP-Complete, are established by
reduction method as explained above. A diagrammatic notation of the
form.
14
The block diagram in 14.5 indicates that , assuming P as already
established to be NP-Complete, the NP- Completeness of Q is
established by a polynomial-time reduction from P to Q.
A
scheme
for
establishing NP-Completeness of some the problems is suggested by
means of Figure 14.6 given below:
The verification of whether every pairs of vertices is
15
connected by an edge in E, is done for different pairs of vertices
by a Non-deterministic TM,
i.e., in parallel. Hence, it takes only polynomial time because for each
of n vertices we need to verify atmost n (n + 1) /2 edges, the
maximum number of edges in a graph with n vertices. Next, we show
that 3-CNF-SAT problem can be transformed to clique problem in
polynomial time.
Take an instance of 3-CNF-SAT. An instance of 3CNF-SAT consists
of a set of n clauses, each consisting of exactly 3 literal, each
being either a variable or negated variable. It is satisfiable if we can
choose literals in such a way that:
• Atleast one literal from each clause is chosen
• If literal of form x is chosen, no literal of form x is considered.
16
For
each
of
the
literals, create a graph node, and connect each node to every node
in other clauses, except those with the same variable but different
sign.

More Related Content

What's hot

7f44bdd880a385b7c1338293ea4183f930ea
7f44bdd880a385b7c1338293ea4183f930ea7f44bdd880a385b7c1338293ea4183f930ea
7f44bdd880a385b7c1338293ea4183f930eaAlvaro
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardAnimesh Chaturvedi
 
Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And ConquerUrviBhalani2
 
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...IJCSIS Research Publications
 
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...mathsjournal
 
(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi DivergenceMasahiro Suzuki
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Traian Rebedea
 
Lindley smith 1972
Lindley smith 1972Lindley smith 1972
Lindley smith 1972Julyan Arbel
 
Icitam2019 2020 book_chapter
Icitam2019 2020 book_chapterIcitam2019 2020 book_chapter
Icitam2019 2020 book_chapterBan Bang
 
Resource theory of asymmetric distinguishability
Resource theory of asymmetric distinguishabilityResource theory of asymmetric distinguishability
Resource theory of asymmetric distinguishabilityMark Wilde
 
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming ProblemPenalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problempaperpublications3
 
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMSON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMScscpconf
 

What's hot (19)

Unit 4
Unit 4Unit 4
Unit 4
 
7f44bdd880a385b7c1338293ea4183f930ea
7f44bdd880a385b7c1338293ea4183f930ea7f44bdd880a385b7c1338293ea4183f930ea
7f44bdd880a385b7c1338293ea4183f930ea
 
A05220108
A05220108A05220108
A05220108
 
Q
QQ
Q
 
Bq25399403
Bq25399403Bq25399403
Bq25399403
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Algorithm Using Divide And Conquer
Algorithm Using Divide And ConquerAlgorithm Using Divide And Conquer
Algorithm Using Divide And Conquer
 
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...
Amelioration of Modeling and Solving the Weighted Constraint Satisfaction Pro...
 
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...
OPTIMAL PREDICTION OF THE EXPECTED VALUE OF ASSETS UNDER FRACTAL SCALING EXPO...
 
Stochastic Processes Homework Help
Stochastic Processes Homework Help Stochastic Processes Homework Help
Stochastic Processes Homework Help
 
Joco pavone
Joco pavoneJoco pavone
Joco pavone
 
(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence(DL hacks輪読) Variational Inference with Rényi Divergence
(DL hacks輪読) Variational Inference with Rényi Divergence
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
 
Unit 3
Unit 3Unit 3
Unit 3
 
Lindley smith 1972
Lindley smith 1972Lindley smith 1972
Lindley smith 1972
 
Icitam2019 2020 book_chapter
Icitam2019 2020 book_chapterIcitam2019 2020 book_chapter
Icitam2019 2020 book_chapter
 
Resource theory of asymmetric distinguishability
Resource theory of asymmetric distinguishabilityResource theory of asymmetric distinguishability
Resource theory of asymmetric distinguishability
 
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming ProblemPenalty Function Method For Solving Fuzzy Nonlinear Programming Problem
Penalty Function Method For Solving Fuzzy Nonlinear Programming Problem
 
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMSON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
ON THE DUALITY FEATURE OF P-CLASS PROBLEMS AND NP COMPLETE PROBLEMS
 

Similar to Bt0080 fundamentals of algorithms2

9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problemsJyotsna Suryadevara
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10chidabdu
 
Skiena algorithm 2007 lecture20 satisfiability
Skiena algorithm 2007 lecture20 satisfiabilitySkiena algorithm 2007 lecture20 satisfiability
Skiena algorithm 2007 lecture20 satisfiabilityzukun
 
Skiena algorithm 2007 lecture21 other reduction
Skiena algorithm 2007 lecture21 other reductionSkiena algorithm 2007 lecture21 other reduction
Skiena algorithm 2007 lecture21 other reductionzukun
 
A Stochastic Limit Approach To The SAT Problem
A Stochastic Limit Approach To The SAT ProblemA Stochastic Limit Approach To The SAT Problem
A Stochastic Limit Approach To The SAT ProblemValerie Felton
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Deepak John
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Traian Rebedea
 
Skiena algorithm 2007 lecture19 introduction to np complete
Skiena algorithm 2007 lecture19 introduction to np completeSkiena algorithm 2007 lecture19 introduction to np complete
Skiena algorithm 2007 lecture19 introduction to np completezukun
 
Np completeness
Np completenessNp completeness
Np completenessRajendran
 
lecture 27
lecture 27lecture 27
lecture 27sajinsc
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1debolina13
 

Similar to Bt0080 fundamentals of algorithms2 (20)

9. chapter 8 np hard and np complete problems
9. chapter 8   np hard and np complete problems9. chapter 8   np hard and np complete problems
9. chapter 8 np hard and np complete problems
 
Internship
InternshipInternship
Internship
 
NP Complete Problems in Graph Theory
NP Complete Problems in Graph TheoryNP Complete Problems in Graph Theory
NP Complete Problems in Graph Theory
 
Algorithm chapter 10
Algorithm chapter 10Algorithm chapter 10
Algorithm chapter 10
 
Skiena algorithm 2007 lecture20 satisfiability
Skiena algorithm 2007 lecture20 satisfiabilitySkiena algorithm 2007 lecture20 satisfiability
Skiena algorithm 2007 lecture20 satisfiability
 
Skiena algorithm 2007 lecture21 other reduction
Skiena algorithm 2007 lecture21 other reductionSkiena algorithm 2007 lecture21 other reduction
Skiena algorithm 2007 lecture21 other reduction
 
Approx
ApproxApprox
Approx
 
A Stochastic Limit Approach To The SAT Problem
A Stochastic Limit Approach To The SAT ProblemA Stochastic Limit Approach To The SAT Problem
A Stochastic Limit Approach To The SAT Problem
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
 
NP completeness
NP completenessNP completeness
NP completeness
 
Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6Algorithm Design and Complexity - Course 6
Algorithm Design and Complexity - Course 6
 
UNIT -IV DAA.pdf
UNIT  -IV DAA.pdfUNIT  -IV DAA.pdf
UNIT -IV DAA.pdf
 
Lecture26
Lecture26Lecture26
Lecture26
 
Skiena algorithm 2007 lecture19 introduction to np complete
Skiena algorithm 2007 lecture19 introduction to np completeSkiena algorithm 2007 lecture19 introduction to np complete
Skiena algorithm 2007 lecture19 introduction to np complete
 
Np completeness
Np completenessNp completeness
Np completeness
 
lecture 27
lecture 27lecture 27
lecture 27
 
Crt
CrtCrt
Crt
 
Teori pnp
Teori pnpTeori pnp
Teori pnp
 
AA ppt9107
AA ppt9107AA ppt9107
AA ppt9107
 
Dynamic programming1
Dynamic programming1Dynamic programming1
Dynamic programming1
 

More from Techglyphs

Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2Techglyphs
 
Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1Techglyphs
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Techglyphs
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Techglyphs
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Techglyphs
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1Techglyphs
 
Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2Techglyphs
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1Techglyphs
 
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2Techglyphs
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Techglyphs
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Techglyphs
 
Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Techglyphs
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Techglyphs
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1Techglyphs
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2Techglyphs
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1Techglyphs
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2Techglyphs
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2Techglyphs
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with javaTechglyphs
 
Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1Techglyphs
 

More from Techglyphs (20)

Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2
 
Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1
 
Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1
 
Bt0066 database management system2
Bt0066 database management system2Bt0066 database management system2
Bt0066 database management system2
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1
 
Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 

Bt0080 fundamentals of algorithms2

  • 1. 1 Fundamentals of Algorithms BT0080 Part-2 By Milan K Antony
  • 2. 2 1.Write the steps involved in the general method for Branch and Bound? Explain? Branch and Bound strategy is a general algorithm for finding optimal solutions of various optimization problems, especially in discrete and combinatorial optimization. It consists of a systematic enumeration of all candidate solutions, where large subsets of fruitless candidates are discarded en masse, by using upper and lower estimated bounds of the quantity being optimized. In the following, we have n kinds of items, 1 through n. Each kind of item i has a value vi and a weight wi. We usually assume that all values and weights are nonnegative. To simplify the representation, we can also assume that the items are listed in increasing order of weight. The maximum weight that we can carry in the bag is W. The most common formulation of the problem is the 0-1 knapsack problem, which restricts the number xi of copies of each kind of item to zero or one. Mathematically the 0-1-knapsack problem can be formulated as:  maximize  subject to The bounded knapsack problem restricts the number xi of copies of each kind of item to a maximum integer value ci. Mathematically the bounded knapsack problem can be formulated as:  maximize  subject to The unbounded knapsack problem (UKP) places no upper bound on the number of copies of each kind of item.
  • 3. 3 Of particular interest is the special case of the problem with these properties:  it is a decision problem,  it is a 0-1 problem,  for each kind of item, the weight equals the value: wi = vi. 1. Algorithm U Bound(cp, cw, k, m) 2. // cp is the current profit total, cw is the current 3. // weight total; k is the index of the last removed 4. // item; and m is the knapsack size 5. // w[i] and p[i] are respectively the weight and profit 6. // of the ith object 7. { 8. b:=cp; c:=cw; 9. for I:=k+1 to n do 10. { 11. if (c+w[i] m) then 12. { 13. c:c+w[i]; b:=b-p[i]; 14. } 15. } 16. return b; 17. } 18. 19. 20. One early application of knapsack algorithms was in the construction and scoring of tests in which the test-takers have a choice as to which questions they answer. On tests with a homogeneous distribution of point values for each question, it is a fairly simple process to provide the test-takers with such a choice. For example, if
  • 4. 4 an exam contains 12 questions each worth 10 points, the test-taker need only answer 10 questions to achieve a maximum possible score of 100 points. However, on tests with a heterogeneous distribution of point values—that is, when different questions or sections are worth different amounts of points— it is more difficult to provide choices. Feuerman and Weiss proposed a system in which students are given a heterogeneous test with a total of 125 possible points. The students are asked to answer all of the questions to the best of their abilities. Of the possible subsets of problems whose total point values add up to 100, a knapsack algorithm would determine which subset gives each student the highest possible score 2. Explain the NP hard and the NP complete problems? The best algorithms for their solutions have computing times that cluster into two groups. The first group consists of problems whose solution are bounded by polynomials of small degree. The second group is made up to problems whose best-known algorithms are non-polynomial. Examples we have seen include the traveling salesperson and the knapsack problems for which the best algorithms given in this text have complexities O (n22n) and O (2n/2) respectively.
  • 5. 5 In the quest to develop efficient algorithms, no one has been able to develop a polynomial time algorithm for any problem in the second group. This is very important because algorithms whose computing times are greater then, polynomial very quickly require such vast amounts of time to execute that even moderate-size problems cannot be solved. The theory of NP-completeness, which we present here, does not provide a method of obtaining polynomial time algorithms for problems in the second group. Nor does it say that algorithms of this complexity do not exist. Instead, what we do is show that many of the problems for which there are 4 no known polynomial time algorithms are computationally related. In fact, we establish two classes of problems. These are given names, NP-hard and NP-Complete. A problem that is NP-Complete has the property that it can be
  • 6. 6 solved in polynomial time if and only if all other NP-Complete problems can also be solved in polynomial time. If an 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 known to be NP-complete. Although one can define many distinct problem classes having the properties stated above for the NP- hard and NP-complete classes, the classes we study are related to non-deterministic computations. The relationship of these classes to non deterministic computations together with the apparent power of non- determinism lead to the intuitive conclusion that no NP- complete or NP- hard problem is polynomially solvable. 3. Briefly explain the concept of trees?
  • 7. 7 A tree is a connected graph without any circuits. The graph in Fig. , for instance, is a tree. Trees with one, two, three and four vertices are shown in Fig. . A graph must have at least one vertex, and therefore so must a tree. Some authors allow the null tree, a tree without any vertices. It follows immediately from the definition that a tree has to be a simple graph, that is, having neither a self-loop nor parallel edges (because they both form circuits). Trees appear in numerous instances. The genealogy of a family is often represented by means of tree (in fact the term tree comes from family tree) A river with its tributaries and subtributaries can be represented by a tree. The sorting of mail according to zip code and the punched cards is done according to a tree (called decision tree or sorting tree).
  • 8. 8 Fig. 9.9 C might represent the flow of mail, all the mail arrives at some local office, vertex N. The most significant digit in the zip code is read at N, and the mail is divided into 10 piles N1, N2, ... N9 and N0 on the most
  • 9. 9 significant digit. Each pile is further divided into 10 piles according to second most significant digit, and so on, till the mail is sub divided into 105 possible piles, each representing a unique five-digit zip code. 4. Prove that “A tree with n vertices has (n – 1) edges”? Step (i): If n = 1, then G contains only one vertex and no edge. So the number of edges in G is n -1 = 1 - 1 = 0. Step (ii): Induction hypothesis: The statement is true for all trees with less than „n vertices.‟ Step (iii): Let us consider a tree with „n vertices.‟ Let „ek be any edge in T whose end vertices are vi and vj.‟ Since T is a tree, there is no other path between vi and vj. So by removing ek from T, we get a disconnected graph. Also, T- ek consists of exactly two components(say T1 and T2). Since T is a tree, there were no circuits in T and so there were no
  • 10. 10 circuits in T1 and T2. Therefore, T1 and T2 are also trees. It is clear that |V(T1)| + |V(T2)| = |V(T)| where V(T) denotes the set of vertices in T. Also, |V(T1)| and |V(T2)| are les than n. Therefore, by the induction hypothesis, we have |E(T1)| = |V(T1)| - 1 and |E(T2)| = |V(T2)| - 1. Now |E(T)| - 1 = |E(T1)| + |E(T2)| = |V(T1)| - 1 + |V(T2)| - 1 Thus |E(T)| = |V(T1)| + |V(T2)| - 1 = |V(T)| - 1 = n-1. 5. Prove that “A connected graph G is a Euler graph if and only if it can be decomposed into circuits” Suppose graph G can be decomposed into circuits; that is, G is a union of edge-disjoint circuits. Since the degree of every vertex in a circuit is two, the degree of every vertex in G is even. Hence, G is an Euler graph. Conversely, let G be a Euler graph. Consider a vertex v1. There are
  • 11. 11 atleast two edges incident at v1. Let one of these edges be between v1 and v2. Since vertex v2 is also of even degree, it must have at least another edge, say between v2 and v3. Proceeding in this fashion, we eventually arrive at a vertex that has previously been traversed, thus forming a circuit . Let us remove from G. All vertices in the remaining graph (not necessarily connected) must also be of even degree. From the remaining graph remove another circuit in exactly the same way as we removed from G. Continue this process until n o edges are left. Hence the theorem. 6. Show that the Clique problem is an NP-complete problem. The process of establishing a problem as NP-Complete is a two step process. The first step, which in most of the cases is quite
  • 12. 12 simple, constitutes of guessing possible solutions of the instances, one instance at a time, of the problem and then verifying whether the gue ss actually is a solution or not. The second step involves designing a polynomial-time algorithm which reduces instances of an already known NP-Complete problem to instances of the problem, which is intended to be shown as NP- Complete. However, to begin with, there is a major hurdle in execution of the second step. The above technique of reduc tion can not be applied unless we already have established atleast one problem as NP-Complete. Therefore, for the first NP-Complete problem, the NP-Completeness has to be established in a different manner. As mentioned earlier, Stephen Cook (1971) established Satisfiability as the first NP-Complete problem. The proof was based on explicit reduction of the language of any non-deterministic, polynomial-time
  • 13. 13 TM to the satisfiability problem. The proof of satisfiability problem as the first NP-Complete problem, is quite lengthy and we skip the proof. Interested readers may consult any of the texts given in the reference. Assuming the satisfiability problem as NP-Complete, the rest of the problems that we establish as NP-Complete, are established by reduction method as explained above. A diagrammatic notation of the form.
  • 14. 14 The block diagram in 14.5 indicates that , assuming P as already established to be NP-Complete, the NP- Completeness of Q is established by a polynomial-time reduction from P to Q. A scheme for establishing NP-Completeness of some the problems is suggested by means of Figure 14.6 given below: The verification of whether every pairs of vertices is
  • 15. 15 connected by an edge in E, is done for different pairs of vertices by a Non-deterministic TM, i.e., in parallel. Hence, it takes only polynomial time because for each of n vertices we need to verify atmost n (n + 1) /2 edges, the maximum number of edges in a graph with n vertices. Next, we show that 3-CNF-SAT problem can be transformed to clique problem in polynomial time. Take an instance of 3-CNF-SAT. An instance of 3CNF-SAT consists of a set of n clauses, each consisting of exactly 3 literal, each being either a variable or negated variable. It is satisfiable if we can choose literals in such a way that: • Atleast one literal from each clause is chosen • If literal of form x is chosen, no literal of form x is considered.
  • 16. 16 For each of the literals, create a graph node, and connect each node to every node in other clauses, except those with the same variable but different sign.