Fundamentals of Algorithms-2

Post on 07-Apr-2018

214 views 0 download

Transcript of Fundamentals of Algorithms-2

  • 8/6/2019 Fundamentals of Algorithms-2

    1/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 arenonnegative. 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

    Thebounded knapsack problemrestricts 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)

  • 8/6/2019 Fundamentals of Algorithms-2

    2/7

    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 object7. {

    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 processto 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

  • 8/6/2019 Fundamentals of Algorithms-2

    3/7

    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.

    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

  • 8/6/2019 Fundamentals of Algorithms-2

    4/7

    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 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?

    A tree is a connected graph without any circuits. The

    graph in Fig. , for instance, is a tree. Trees with one,

  • 8/6/2019 Fundamentals of Algorithms-2

    5/7

    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/6/2019 Fundamentals of Algorithms-2

    6/7

  • 8/6/2019 Fundamentals of Algorithms-2

    7/7

    ////////////////////////////////////////////////////////

    For full Version visit

    http://smudeassignments.blogspot.com/

    This work is licensed under the Creative CommonsAttribution-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.

    ///////////////////////////////////////////////////////

    http://smudeassignments.blogspot.com/http://smudeassignments.blogspot.com/