Vous êtes sur la page 1sur 7

Fundamentals of Algorithms-2 .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. 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 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 valuesthat 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. salesperson

Examples we have seen include the traveling

and the knapsack problems for which the best algorithms given in this text have complexities O (n22n) and O

(2n/2) respectively. In the quest to develop efficient algorithms, no one has been able to develop a polynomial time algorithm for any very important are greater

problem in the second group. This is because algorithms whose computing

times

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 group. Nor does it

algorithms for problems in the second

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 solved in other NP-Complete polynomial time if and only if all 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 classes we study are related to

NP-complete classes, the

non-deterministic computations. The relationship of these classes to non deterministic computations together with the apparent power of nondeterminism lead to the

intuitive conclusion that no NP- complete or NP- hard problem is polynomially solvable.

3.Briefly explain the concept of trees? 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 therefore so must a

must have at least one vertex, and

tree. Some authors allow the null tree, a tree without any vertices. It follows immediately from the definition graph, that is, having

that a tree has to be a simple

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 according to a

zip code and the punched cards is done

tree (called decision tree or sorting tree).

Fig. 9.9 C might represent the flow of

//////////////////////////////////////////////////////// For full Version visit http://smudeassignments.blogspot.com/

This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. ///////////////////////////////////////////////////////

Vous aimerez peut-être aussi