DAA QB 1.pdf

24
http://csetube.tk/ http://csetube.tk/ CS2251 – DESIGN AND ANALYSIS OF ALGORITHMS Question Bank UNIT - I 1.What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate input in finite amount of time. 2. What are the three different algorithms used to find the gcd of two numbers? The three algorithms used to find the gcd of two numbers are 1. Euclid’s algorithm 2. Consecutive integer checking algorithm 3. Middle school procedure 3.What are the fundamental steps involved in algorithmic problem solving? The fundamental steps are 1 .Understanding the problem 2. Ascertain the capabilities of computational device 3. Choose between exact and approximate problem solving 4. Decide on appropriate data structures 5. Algorithm design techniques 6. Methods for specifying the algorithm 7. Proving an algorithms correctness 8. Analyzing an algorithm 9 Coding an algorithm 4. What is an algorithm design technique? An algorithm design technique is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computing. 5. What is pseudocode? http://csetube.weebly.com/ http://csetube.weebly.com/

Transcript of DAA QB 1.pdf

  • http://csetube.tk/

    http://csetube.tk/

    CS2251 DESIGN AND ANALYSIS OF ALGORITHMS

    Question Bank

    UNIT - I1.What is an algorithm?

    An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaininga required output for any legitimate input in finite amount of time.

    2. What are the three different algorithms used to find the gcd of two numbers?

    The three algorithms used to find the gcd of two numbers are

    1. Euclids algorithm

    2. Consecutive integer checking algorithm

    3. Middle school procedure

    3.What are the fundamental steps involved in algorithmic problem solving?

    The fundamental steps are

    1 .Understanding the problem

    2. Ascertain the capabilities of computational device

    3. Choose between exact and approximate problem solving

    4. Decide on appropriate data structures

    5. Algorithm design techniques

    6. Methods for specifying the algorithm

    7. Proving an algorithms correctness

    8. Analyzing an algorithm

    9 Coding an algorithm

    4. What is an algorithm design technique?

    An algorithm design technique is a general approach to solving problems algorithmically that isapplicable to a variety of problems from different areas of computing.

    5. What is pseudocode?

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    A pseudocode is a mixture of a natural language and programming language constructs tospecify an algorithm. A pseudocode is more precise than a natural language and its usage oftenyields more concise algorithm descriptions.

    5. What are the types of algorithm efficiencies?

    The two types of algorithm efficiencies are

    1. Time efficiency: indicates how fast the algorithm runs

    2.Space efficiency: indicates how much extra memory the algorithm needs

    6. Mention some of the important problem types?

    Some of the important problem types are as follows

    1.Sorting

    2. Searching

    3. String processing

    4. Graph problems

    5. Combinatorial problems

    6. Geometric problems

    7. Numerical problems

    7. What are the classical geometric problems?

    The two classic geometric problems are

    1.The closest pair problem: given n points in a plane find the closest pair among them

    2. The convex hull problem: find the smallest convex polygon that would include all the pointsof a given set.

    8. What is the basic operation of an algorithm and how is it identified?

    The most important operation of the algorithm is called the basic operation of the algorithm, theoperation that contributes the most to the total running time. It can be identified easily because itis usually the most time consuming operation in the algorithms innermost loop.

    9. What is the running time of a program implementing the algorithm?

    The running time T(n) is given by the following formula

    T(n) copC(n)

    cop is the time of execution of an algorithms basic operation on a particular computer and C(n)is the number of times this operation needs to be executed for the particular algorithm.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    10. What are exponential growth functions?

    The functions 2n and n! are exponential growth functions, because these two functions grow sofast that their values become astronomically large even for rather smaller values of n.

    11. What is worst-case efficiency?

    The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size n,which is an input or inputs of size n for which the algorithm runs the longest among all possibleinputs of that size.

    12. What is best-case efficiency?

    The best-case efficiency of an algorithm is its efficiency for the best-case input of size n, whichis an input or inputs for which the algorithm runs the fastest among all possible inputs of that size

    13. What is average case efficiency?

    The average case efficiency of an algorithm is its efficiency for an average case input of size n. Itprovides information about an algorithm behavior on a typical or random input.

    14. What is amortized efficiency?

    In some situations a single operation can be expensive, but the total time for the entire sequenceof n such operations is always significantly better that the worst case efficiency of that singleoperation multiplied by n. this is called amortized efficiency.

    15. Define O-notation?

    A function t(n) is said to be in O(g(n)), denoted by t(n) O(g(n)), if t(n) is bounded above bysome constant multiple of g(n) for all large n, i.e., if there exists some positive constant c andsome nonnegative integer n0 such that

    T(n) cg(n) for all n n0

    16. Define -notation?

    A function t(n) is said to be in (g(n)), denoted by t(n) (g(n)), if t(n) is bounded below bysome constant multiple of g(n) for all large n, i.e., if there exists some positive constant c andsome nonnegative integer n0 such that

    T(n) cg(n) for all n n0

    17. Define -notation?

    A function t(n) is said to be in (g(n)), denoted by t(n) (g(n)), if t(n) is bounded both above& below by some constant multiple of g(n) for all large n, i.e., if there exists some positiveconstants c1 & c2 and some nonnegative integer n0 such that c2g(n) t(n) c1g(n) for all n n0

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    18. Mention the useful property, which can be applied to the asymptotic notations and its use?

    If t1(n) O(g1(n)) and t2(n) O(g2(n)) then t1(n)+t2(n) max {g1(n),g2(n)} this property is also true for and notations. This property will be useful in analyzing algorithms that comprise o

    19. What is the recurrence relation to find out the number of multiplications and

    the initial condition for finding the n-th factorial number?

    The recurrence relation and initial condition for the number of multiplications Is M(n)=M(n-1)+1for n>0

    M(0)=0f two consecutive executable parts.

    20. Write the general plan for analyzing the efficiency for recursive algorithms.

    The various steps include ._

    1.Decide on a parameter indicating inputs size.

    2.Identify the algorithms basic operation.

    3.Check whether the number of times the basic operation is executed

    depends on size of input. If it depends on some additional property the

    worst, average and best-case efficiencies have to be investigated

    separately.

    4.Set up a recurrence relation with the appropriate initial condition , for

    the number of times the basic operation is executed.

    5.Solve the recurrence or at least ascertain the orders of growth of its solution.

    16 MARKS

    1.Discuss the Asymptotic notations with efficiency classes and examples

    2. (a). Define the asymptotic notations used for best case average case and worst case

    analysis of algorithm. (8)

    (b)Write an algorithm for finding maximum element of an array; perform best and

    average case complexity with appropriate order notations. (8)

    3. Write an algorithm to find mean and variance of an array perform best, worst and

    average case complexity, defining the notations used for each type of analysis.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    4.Using the recursive algorithm ,explain how the tower of Hanoi problem can be solved. What will be timea nd space complexity for the algorithms.

    5. Explain linear search with example

    UNIT-II

    1.Give the general plan for divide-and-conquer algorithms.

    The general plan is as follows

    1. A problems instance is divided into several smaller instances of the same problem, ideallyabout the same size

    2. The smaller instances are solved, typically recursively

    3. If necessary the solutions obtained are combined to get the solution of the original problem

    2.What is the general divide-and-conquer recurrence relation?

    An instance of size n can be divided into several instances of size n/b, with a of them needingto be solved. Assuming that size n is a power of b, to simplify the analysis, the followingrecurrence for the running time is obtained:

    T(n) = aT(n/b)+f(n)

    Where f(n) is a function that accounts for the time spent on dividing the problem into smallerones and on combining their solutions.

    3. Define mergesort.

    Mergesort sorts a given array A[0..n-1] by dividing it into two halves a[0..(n/2)-1] and A[n/2..n-1] sorting each of them recursively and then merging the two smaller sorted arrays into a singlesorted one.

    4. What is the difference between quicksort and mergesort?

    Both quicksort and mergesort use the divide-and-conquer technique in which the given array ispartitioned into subarrays and solved. The difference lies in the technique that the arrays arepartitioned. For mergesort the arrays are partitioned according to their position and in quicksortthey are partitioned according to the element values.

    5. What is binary search?

    Binary search is a remarkably efficient algorithm for searching in a sorted array. It works bycomparing a search key K with the arrays middle element A[m]. if they match the algorithm

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    stops; otherwise the same operation is repeated recursively for the first half of the array if K A[m].

    6. What are the classic traversals of a binary tree?

    The classic traversals are as follows ._Preorder traversal: the root is visited before left & rightsubtrees ._Inorder traversal: the root is visited after visiting left subtree and

    before visiting right subtree ._Postorder traversal: the root is visited after visiting the left andright subtrees

    7. what is knapsack problem ?

    knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a weightand a value, determine the count of each item to include in a collection so that the total weight is less thanor equal to a given limit and the total value is as large as possible. It derives its name from the problemfaced by someone who is constrained by a fixed-size knapsack and must fill it with the most useful items.

    8. Give the formula used to find the upper bound for knapsack problem.

    A simple way to find the upper bound ub is to add v, the total value

    of the items already selected, the product of the remaining capacity of the

    knapsack W-w and the best per unit payoff among the remaining items, which

    is vi+1/wi+1

    ub = v + (W-w)( vi+1/wi+1)

    9. What is greedy technique?

    Greedy technique suggests a greedy grab of the best alternative available in the hope that asequence of locally optimal choices will yield a globally optimal solution to the entire problem.The choice must be made as

    follows .

    Feasible : It has to satisfy the problems constraints ._

    Locally optimal : It has to be the best local choice among all feasible

    choices available on that step. .

    Irrevocable : Once made, it cannot be changed on a subsequent step of the algorithm

    10. Define control abstraction.

    A control abstraction we mean a procedure whose flow of control is clear but whose primaryoperations are by other procedures whose precise meanings are left undefined.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    11. What is the substitution method?

    One of the methods for solving any such recurrence relation is called the substitution method

    12. What is the maximum and minimum problem?

    The problem is to find the maximum and minimum items in a set of n

    elements.Though this problem may look so simple as to be contrived, it allows us to demonstrate divideand conquer in simple setting

    13. Write a algorithm for straightforward maximum and minimum

    algorithm straight MaxMin(a,n,max,min)

    //set max to the maximum and min to the minimum of a[1:n]

    {

    max := min: = a[i];

    for i = 2 to n do

    {

    if(a[i] >max) then max: = a[i];

    if(a[i] >min) then min: = a[i];

    }

    }

    14. Write the algorithm for Iterative binary search?

    Algorithm BinSearch(a,n,x)

    //Given an array a[1:n] of elements in nondecreasing

    // order, n>0, determine whether x is present

    {

    low : = 1;

    high : = n;

    while (low < high) do

    {

    mid : = [(low+high)/2];

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    if(x < a[mid]) then high:= mid-1;

    else if (x >a[mid]) then low:=mid + 1;

    else return mid;

    }

    return 0;

    }

    15. Describe the recurrence relation of merge sort?

    If the time for the merging operation is proportional to n, then the computing

    time of merge sort is described by the recurrence relation

    n = 1, a a constant

    T(n) = a

    2T (n/2) + n n >1, c a constant

    16. Write any two characteristics of Greedy Algorithm?

    o To solve a problem in an optimal way construct the solution from given set of

    candidates.

    o As the algorithm proceeds, two other sets get accumulated among this one set

    contains the candidates that have been already considered and chosen while

    the other set contains the candidates that have been considered but rejected.

    17. Give the recurrence relation of divide-and-conquer?

    The recurrence relation is

    T(n) = g(n)

    T(n1) + T(n2) + ----+ T(nk) + f(n)

    18. Give computing time for Bianry search?

    The computing time of binary search by giving formulas that describe the best,

    average and worst cases. Successful searches q(1) q(logn) q(Logn) best average worst

    unsuccessful searches q(logn) best, average, worst.

    19. Write the Control abstraction for Divide-and conquer.

    Algorithm D And(r)

    {

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    if small(p) then return S(r);

    else

    {

    divide P into smaller instance _ 1, _ 2, _ k, k 1;

    Apply D and C to each of these subproblems

    Return combine (DAnd C(_1) DAnd C(_2),----, DAnd ((_k));

    }

    }

    20. Write the Anlysis for the Quick sot.

    In analyzing QUICKSORT, we can only make the number of element comparisions c(n). It is easy to seethat the frequency count of other operations is of the same order as C(n).

    21. What is the Greedy choice property?

    solution can arrive at by making a locally optimal choice.

    cannot depend on any future choices or on solution to the sub problem.

    16 MARKS

    1.. Explain Knapsack Problem (16).

    2. Explain the algorithm for maximum and minimum numbers in an array.

    (16)

    3. (a) Give a detailed note on Divide and Conquer techniques.(6)

    (b). Sort the following set of elements using merge sort (10)

    12,24,8,71,4,23,6,89,56

    4. Write An algorithm for searching an element using Binary search

    method. Give an example. (16)

    5. (a) write a pseudo code for a divide and conquer algorithm for

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    merging two sorted arrays into a single sorted one. Explain with an

    example. (12)

    (b) Setup an solve a recurrence relation for the number of key

    comparisons made by the above pseudo code. (4)

    6. Explain in detail merge sort. Illustrate the algorithm with a numeric example. Providecomplete analysis of the same

    UNIT -III

    1.What is the use of TVSP?

    In places where the loss exceeds the tolerance level boosters have to the

    placed. Given a network and loss tolerance level the tree vertex splitting problems is

    to determine an optimal placement of boosters.

    Thus it is always safe to make greedy choice.

    choice are empty.

    SNSCT Department of Compute Science and Engineering Page 10

    2. Write the specification of TVSP

    Let T= (V, E, W) be a weighted directed binary tree where

    V_ vertex set

    E_ edge set

    W_ weight function for the edge.

    W is more commonly denoted as w (i,j) which is the weight of the edge _E.

    3. Define feasible solution for TVSP.

    Given a weighted tree T(V,E,W) and a tolerance limit _ any subset X of V is a

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    feasible solution if d(T/X).

    4. Define optimal solution for TVSP.

    An optimal solution is one in which the number of nodes in X is minimized

    5. Write the difference between the Greedy method and Dynamic programming.

    Greedy method Dynamic programming

    Only one sequence of decision is Many number of decisions are

    generated. generated1.

    Greedy method Dynamic Programming

    It does not guarantee to give an It definitely gives an optimal

    solution always. optimal solution always.

    6. Define dynamic programming.

    Dynamic programming is an algorithm design method that can be used when a

    solution to the problem is viewed as the result of sequence of decisions.

    7. What are the features of dynamic programming?

    their values.

    considered.

    8. Write the general procedure of dynamic programming.

    The development of dynamic programming algorithm can be broken into a

    sequence of 4 steps.

    1. Characterize the structure of an optimal solution.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    2. Recursively define the value of the optimal solution.

    3. Compute the value of an optimal solution in the bottom-up fashion.

    4. Construct an optimal solution from the computed information.

    9. Define principle of optimality.

    It states that an optimal sequence of decisions has the property that whenever

    the initial stage or decisions must constitute an optimal sequence with regard to

    stage resulting from the first decision.

    10. Give an example of dynamic programming and explain.

    An example of dynamic programming is knapsack problem. The solution to

    the knapsack problem can be viewed as a result of sequence of decisions. We have

    to decide the value of xi for 1

  • http://csetube.tk/

    http://csetube.tk/

    The formula to calculate optimal solution is

    g0(m)=max{g1, g1(m-w1)+p1}.

    14. Write some applications of traveling salesperson problem.

    assembly line.

    the same set of machines.

    15. Give the time complexity and space complexity of traveling salesperson

    problem.

    16.Define finish time

    The finish time fi (S) of job i is the time at which all tasks of job i have been

    completed in schedule S.The finish time F(S) of schedule S is given by F(S)=max{ fi

    (S)} 1

  • http://csetube.tk/

    http://csetube.tk/

    19. Define preemptive optimal finish time.

    Preemptive optimal finish time scheduling for a given set of tasks is a

    preemptive schedule S for which F (S) is minimum over all preemptive schedules S.

    20. Define state space of the problem.

    All the paths from the root of the organization tree to all the nodes is called as

    state space of the problem

    16MARKS

    1.How will you construct a optimal search tree with example. (16)

    2. Explain the Multistage graph with example. (16)

    3. Explain the 0/1 knapsack with an algorithm. (16)

    4. Describe the Traveling salesman problem & discuss how to solve it usingDynamic Programming(16)

    5. Solve the all-pairs shorest path problem for the digraph with any example?

    UNIT IV

    1.,What are the factors that influence the efficiency of the backtracking algorithm?

    The efficiency of the backtracking algorithm depends on the following four

    factors. They are:

    i. The time needed to generate the next xk

    ii. The number of xk satisfying the explicit constraints.

    iii. The time for the bounding functions Bk

    iv. The number of xk satisfying the Bk.

    2.Define Branch-and-Bound method.

    The term Branch-and-Bound refers to all the state space methods in which all

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    children of the E-node are generated before any other live node can become the E- node.

    3.What are the searching techniques that are commonly used in Branch-and-Bound

    method.

    The searching techniques that are commonly used in Branch-and-Bound method

    are:

    i. FIFO

    ii. LIFO

    iii. LC

    iv. Heuristic search

    4.State 8 Queens problem.

    The problem is to place eight queens on a 8 x 8 chessboard so that no two queen

    attack that is, so that no two of them are on the same row, column or on the diagonal.

    5.State Sum of Subsets problem.

    Given n distinct positive numbers usually called as weights , the problem calls for finding all

    the combinations of these numbers whose sums are m.

    6. State m colorability decision problem.

    Let G be a graph and m be a given positive integer. We want to discover whether the nodes of

    G can be colored in such a way that no two adjacent nodes have the same color yet only m

    colors are used.

    7.Define chromatic number of the graph.

    The m colorability optimization problem asks for the smallest integer m for which the

    graph G can be colored. This integer is referred to as the chromatic number of the graph.

    8.Define Backtracking.

    Backtracking is to build up the solution vector one component at a time and to use

    modified criterion function Pi(x1,..,xi) (sometimes called bounding function) to test whether

    the vector being formed has any chance of success. Desired solution expressed as an ntuple

    (x1,x2,,xn) where xi are chosen from some set Si.

    If |Si|=mi, m=m1m2..mn candidates are possible

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    Yielding the same answer with far fewer than m trials

    Advantage : if it is realized that the partial vector (x1,..,xi) can in no way lead to an

    optimum solution, then mi+1mn possible test vectors can be ignored entirely.

    9.Give the categories of the problem in backtracking.

    - Whether there is any feasible solution.

    - Whether there exists any best solution.

    - Finds all possible feasible solution.

    10. List down the examples of backtracking.

    -Queens problem

    -Sum problem

    11. What are the two types of constraints used in Backtracking?

    12. Define implicit constraint.

    rules that determine which of the tuples in the solution

    space of I that satisfy the criterion function.

    9. Define explicit constraint.

    Explicit constraints are rules that restrict each xi to take on values only from a given set.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    I

    constraints

    xi >= 0, or Si = {all nonnegative real numbers}

    xi = {0, 1} or Si = { 0, 1 }

    li

  • http://csetube.tk/

    http://csetube.tk/

    16. Define m color ability decision problem.

    Let G be a graph and m be a given positive integer. The nodes of G can be colored in such

    a way that no two adjacent nodes have the same color yet only m colors are used. This is

    termed the m-colorability decision problem. If d is the degree of the given graph, then it

    can be colored with d+ 1 color. The m-colorability optimization problem asks for the

    smallest integer m for which the graph G can be colored. This integer is referred to as the

    chromatic number of the graph. The color of each node is indicated next to it. If three

    colors are needed to color the graph then the graphs chromatic number is 3.

    17.Define promising and non promising node.

    Promising Node:

    A node in a state space tree is said to be promising if it corresponds to a

    partially constructed solution that may still lead to a complete solution.

    Non Promising node:

    A node in a state space tree is said to be non-promising if it corresponds to

    a partially constructed solution that would not be able to lead to a complete

    solution further.

    18. How can you represent the solution for 8 queens problem?

    All solutions represented as 8-tuples (x1, x2,, x8) where xi is the column on which

    queen i is placed.

    Constraints are,

    Explicit constraints

    Si={1,2,,8}

    Implicit constraints

    1. No two xis can be the same column or row (By this, solution space

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    reduced from 88 to 8!)

    2. No two queens can be on the same diagonal

    19. Define problem state & state space?

    is each node in the depth-first search tree

    20. Define sum of subsets problem?

    In the Sum-of-Subsets problem, there are n positive integers (weights) wi and a positive

    integer W.

    The goal is to find all subsets of the integers that sum to W.

    For example, n = 4, w = (11, 13, 24, 7), and m = 31, the desired subsets are (11, 13, 7)

    and (24, 7)

    The solution vectors can also be represented by the indices of the numbers as (1, 2, 4)

    and (3, 4)

    _ All solutions are k-tuples, 1

  • http://csetube.tk/

    http://csetube.tk/

    problems.s=(1,3,4,5) & d=11 (16)

    6. Explain subset-sum problem and discuss the possible solution strategies using

    backtracking. (16)

    7. Explain 8-Queens problem with an algorithm. Explain why backtracking is defined as

    a default procedure of last resort for solving problems. (10+6)

    8. Using Backtracking enumerate how can you solve the following problems

    (a) 8-queens problem (8)

    (b) Hamiltonian circuit problem (8)

    UNIT-V

    1. Define graph traversal.

    Searching a vertex in a graph can be solved by starting at vertex V and

    systematically searching the graph G for vertices that can be reached from V.

    It starts at initial vertex and visits each and every vertex exactly once and finally reaches

    end vertex.

    2. Mention the types of traversal.

    (i)

    (ii)Depth first search traversal.

    3. What is meant by BFS traversal?

    (i)

    (ii)

    (iii)

    (iv) ocess is repeated until no more vertexes is left

    4. What is the time complexity of BFS?

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    (i)

    (ii)If the graph is represented by adjacency List: O (|V|+ |E| ).

    5. Define depth first search traversal.

    (i)

    (ii)

    (iii)

    (iv)

    (v) e search terminates when all reached vertices have been fully explored.

    6. What is the time complexity of DFS?

    (i)

    (ii)

    7.Define connected component.

    (i)

    path from U to V.

    (ii)

    8. How do identify connected component using breath first search?

    (i)

    (ii)

    (iii)

    9. Define spanning tree.

    (i) nimal sub graph, G', of G such that V (G') = V (G) and G' is

    connected

    (ii)

    (iii) -1edges, and all

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    connected graphs with n -1 edges are trees

    (iv)A spanning tree has n -1 edge

    10.Define bi connected graph and bi connected component.

    (i)

    (ii)A bi connected component of a connected undirected graph is a maximal bi

    connected sub graph of G

    11.What is tree edge and cross edge?

    In the breath first search forest, whenever a new unvisited vertex is reached for the first

    time, it is attached as a child to the vertex from which it is being reached. Such an edge is

    called tree edge. If an edge is leading to a previously visited vertex other than its

    immediate predecessor, that is noted as a cross edge.

    12.Define branch and bound.

    Branch-and-bound refers to all state space search methods in which all children of an Enode

    are generated before any other live node can become the E-node.

    13.Define live node, E-node and dead node.

    (i)

    generated.

    (ii)E-node is a live node whose children are currently being explored. In other words,

    an E-node is a node currently being expanded.

    (iii)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.

    14.What are the types search strategies in branch and bound?

    (i)

    (ii)

    (iii)

    15. Compare the FIFO and LIFO search.

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    (i)

    (ii)

    (iii)

    (iv)

    16. What is meant by Class NP (Non Polynomial)?

    Class P consists of problems whose solutions are bounded by the non polynomial.

    Examples are Traveling salesperson problem O(n22n), knapsack problem O(2n/2)

    17. What are the two classes of non polynomial time problems?

    (i)NP- hard

    (ii) -complete

    18. What is meant by NP hard and NP complete problem?

    (i) -Hard Problem: A problem L is NP-hard if any only if satisfiability reduces to L.

    (ii) - Complete: A problem L is NP-complete if and only if L is NP-hard and L NP.

    (iii) -hard problems that are not NP-complete.

    19. Define intelligent function.

    Let g(x) be an estimate of the additional effort needed to reach an answer from node x, x

    is assigned a rank using a function c (.) such that

    ^c (x) = f(h(x)) + g(x)

    Where h(x) is the cost of reaching x from root and f (.) is any non decreasing function.

    20.What is meant by class P (Polynomial)?

    Class P consists of problems whose solutions are bounded by the polynomial of small

    degree. Examples are Binary search O(log n), sorting O(n log n), and matrix

    multiplication 0(n 2.81).

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/

  • http://csetube.tk/

    http://csetube.tk/

    16 MARKS

    1. Define spanning tree? Discuss the design steps in prims algorithm to construct

    minimum spanning tree with example. (16)

    2. Explain the method of binding the minimum spanning tree for a connected graph

    using prims algorithm. (16)

    3. Define spanning tree? Discuss the design steps in kruskal algorithm to construct

    minimum spanning tree with example (16)

    4. Compare and contrast the depth first search and birth first search. How do they fit

    in to the decrease and conquer strategies. (16)

    5. Explain NP-hard and NP complete problems with example. (16)

    6. Explain connected components and bi-connected components with psecdocode.

    (16)

    7. Give a suitable example and explain the birth first search and depth first search

    algorithm. (16)

    8. What is branch and bound? Explain detail. (16)

    http://csetube.weebly.com/http://csetube.weebly.com/

    http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/http://csetube.weebly.com/