0 valutazioniIl 0% ha trovato utile questo documento (0 voti)

24 visualizzazioni12 pagineQuestion Bank

Oct 08, 2013

© Attribution Non-Commercial (BY-NC)

DOCX, PDF, TXT o leggi online da Scribd

Question Bank

Attribution Non-Commercial (BY-NC)

0 valutazioniIl 0% ha trovato utile questo documento (0 voti)

24 visualizzazioni12 pagineQuestion Bank

Attribution Non-Commercial (BY-NC)

Sei sulla pagina 1di 12

Section A

1. Brief about the internal nodes in optimal binary search tree

In obtaining a cost function for binary search tree, it is useful to add fictitious node at the place of every empty sub-tree in the search tree. Such nodes are called external nodes. All other nodes are called internal nodes.

In obtaining a cost function for binary search tree, it is useful to add fictitious node at the place of every empty sub-tree in the search tree. Such nodes are called external nodes. Every external node represents a point where a unsuccessful search may terminate.

Explicit constraints are rules that restrict each xi to take on values only from a given set. Explicit constraints depend on the particular instance I of problem being solved All tuple that satisfy the explicit constraints define a possible solution space for I Examples of explicit constraints xi _ 0, or all nonnegative real numbers xi = {0, 1} li xi ui

Implicit constraints are rules that determine which of the tuple in the solution space of I satisfy the criterion function. Implicit constraints describe the way in which the xi s must relate to each other.

Solution space is number of possible answers. When applying explicit constraints only: The solution space for 8-Queens problem is 8 8 tuple. That is 8*8*8*8*8*8*8*8*8 = 16777216.This much of possible answers in 8-Queens problem. After applying implicit constraints, the solution space is reduced to 8! tuple. That is 1* 2* 3 *4 *5* 6* 7* 8 =40320

In the mathematical field of graph theory, a Hamiltonian path (or traceable path) is a path in an undirected graph which visits each vertex exactly once. A Hamiltonian cycle (or Hamiltonian circuit) is a cycle in an undirected graph which visits each vertex exactly once and also returns to the starting vertex. Determining whether such paths and cycles exist in graphs is the Hamiltonian path problem which is NP-complete.

A Hamiltonian path or traceable path is a path that visits each vertex exactly once. A graph that contains a Hamiltonian path is called a traceable graph. A graph is Hamiltonconnected if for every pair of vertices there is a Hamiltonian path between the two vertices. A Hamiltonian cycle, Hamiltonian circuit, vertex tour or graph cycle is a cycle that visits each vertex exactly once (except the vertex which is both the start and end, and so is visited twice). A graph that contains a Hamiltonian cycle is called a Hamiltonian graph. Similar notions may be defined for directed graphs, where each edge (arc) of a path or cycle can only be traced in a single direction (i.e., the vertices are connected with arrows and the edges traced "tail-to-head").

Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges, but a Hamiltonian path can be extended to Hamiltonian cycle only if its endpoints are adjacent.

A state space tree is a rooted tree where each level represents a choice in the solution space that depends on the level above and any possible solution is represented by some path starting out at the root (by definition the root has level zero and represents the state where no partial solution has been made) and ending at a leaf. A leaf has no children and represents the state where all choices making up a solution have been made.

10. Differentiate Backtracking and Branch and Bound. (Or) What is Difference between backtracking and branch and bound method?

Backtracking 1. 2. 3. 4. 5. It is used to find all possible solutions available to the problem. It traverse tree by DFS(Depth First Search). It realizes that it has made a bad choice & undoes the last choice by backing up. It searches the state space tree until it found a solution. It involves feasibility function.

Branch-and-Bound (BB) 1. It is used to solve optimization problem. 2. It may traverse the tree in any manner, DFS or BFS. 3. It realizes that it already has a better optimal solution that the pre-solution leads to so it abandons that pre-solution. 4. It completely searches the state space tree to get optimal solution. 5. It involves bounding function.

A branch-and-bound procedure requires two tools. The first tool is a splitting (or branching) procedure, given a set S of candidates, returns two or more smaller sets whose union covers S. Note that the minimum of f(x) over S is, where each vi is the minimum of f(x) within Si. This step is called branching, since its recursive application defines a tree structure (the search tree) whose nodes are the subsets of S. Second tool is a procedure that computes upper and lower bounds for the minimum value of f(x) within a given subset S. This step is called bounding.

In a traveling salesman problem, if travel time between each pair of nodes is the same in either direction then it is called symmetric travelling salesman problem.

In a traveling salesman problem, if travel time between each pair of nodes is not same in either direction then it is called asymmetric travelling salesman problem.

If the numbers of agents and tasks are equal and the total cost of the assignment for all tasks is equal to the sum of the costs for each agent (or the sum of the costs for each task, which is the same thing in this case), then the problem is called the linear assignment problem.

The key idea of the BB algorithm is: if the lower bound for some tree node (set of candidates) A is greater than the upper bound for some other node B, then A may be safely discarded from the search. This step is called pruning, and is usually implemented by maintaining a global variable m (shared among all nodes of the tree) that records the minimum upper bound seen among all sub-regions examined so far. Any node whose lower bound is greater than m can be discarded

In mathematics, a polynomial is an expression of finite length constructed with variables and constants, using only the operations of addition, subtraction, multiplication, and non-negative, whole-number exponents. For example, x2 4x + 7 is a polynomial, but x2 4/x + 7x3/2 is not, because its second term

involves division by the variable x (4/x) and because its third term contains an exponent that is not a whole number (3/2). The term 'polynomial' indicates a simplified algebraic form such that all polynomials are similarly simple in complexity.

A problem is assigned to the P (polynomial time) class if there exists at least one algorithm to solve that problem, such that the number of steps of the algorithm is bounded by a polynomial in , where is the length of the input.

A problem is assigned to the NP (nondeterministic polynomial time) class if it is solvable in polynomial time by a nondeterministic Turing machine.

A Turing machine is a theoretical device that manipulates symbols on a strip of tape. Despite its simplicity, a Turing machine can be adapted to simulate the logic of any computer algorithm, and is particularly useful in explaining the functions of a CPU inside a computer.

In theoretical computer science, a computational problem is a mathematical object representing a collection of questions that computers might solve. For example, the problem of factoring "Given a positive integer n, find a nontrivial prime factor of n." is a computational problem. Computational problems are one of the main objects of study in theoretical computer science. The field of algorithms studies methods of solving computational problems efficiently. The complementary field of computational complexity attempts to explain why certain computational problems are intractable for computers. A computational problem can be viewed as an infinite collection of instances together with a solution for every instance. For example in the factoring problem, the instances are the integers n, and solutions are prime numbers p that describes nontrivial prime factors of n. It is conventional to represent both instances and solutions by binary strings, namely elements of {0, 1}. For example, numbers can be represented as binary strings using the binary encoding.

Approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation algorithms are often associated with NP-hard problems; since it is unlikely that there can ever be efficient polynomial time exact algorithms solving NP-hard problems, one settles for polynomial time sub-optimal solutions. A typical example for an approximation algorithm is the one for vertex cover in graphs: find an uncovered edge and add both endpoints to the vertex cover, until none remain. It is clear that the

resulting cover is at most twice as large as the optimal one. This is a constant factor approximation algorithm with a factor of 2.

In computability theory and computational complexity theory, a decision problem is a question in some formal system with a yes-or-no answer, depending on the values of some input parameters. For example, the problem "given two numbers x and y, does x evenly divide y?" is a decision problem. The answer can be either 'yes' or 'no', and depends upon the values of x and y. Decision problems are closely related to function problems, which can have answers that are more complex than a simple 'yes' or 'no'. A corresponding function problem is "given two numbers x and y, what is x divided by y?". They are also related to optimization problems, which are concerned with finding the best answer to a particular problem. A method for solving a decision problem given in the form of an algorithm is called a decision procedure for that problem. A decision procedure for the decision problem "given two numbers x and y, does x evenly divide y?" would give the steps for determining whether x evenly divides y, given x and y. One such algorithm is long division, taught to many school children. If the remainder is zero the answer produced is 'yes', otherwise it is 'no'. A decision problem which can be solved by an algorithm, such as this example, is called decidable. The field of computational complexity categorizes decidable decision problems by how difficult they are to solve. "Difficult", in this sense, is described in terms of the computational resources needed by the most efficient algorithm for a certain problem. The field of recursion theory, meanwhile, categorizes undecidable decision problems by Turing degree, which is a measure of the non-computability inherent in any solution.

In mathematics and computer science, an optimization problem is the problem of finding the best solution from all feasible solutions. In the field of approximation algorithms, algorithms are designed to find near-optimal solutions to hard problems. The usual decision version is then an inadequate definition of the problem since it only specifies acceptable solutions. Even though we could introduce suitable decision problems, the problem is more naturally characterized as an optimization problem.

Properties Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges, but a Hamiltonian path can be extended to Hamiltonian cycle only if its endpoints are adjacent. The line graph of a Hamiltonian graph is Hamiltonian. The line graph of an Eulerian graph is Hamiltonian. A tournament (with more than 2 vertices) is Hamiltonian if and only if it is strongly connected.

A Hamiltonian cycle may be used as the basis of a zero-knowledge proof. Number of different Hamiltonian cycles for a complete graph = (n-1)! / 2. Number of different Hamiltonian cycles for a complete directed graph = (n-1)!.

25. Brief Branch and Bound 26. Define greedy for continuous Knapsack problem 27. Define greedy for 0/1 Knapsack Problem 28. Define NP hard problem 29. Define NP complete 30. Define heuristic 31. Formula for approximation problem 32. Formula for travelling sales person 33. Write the adjacency matrix of the following graph 34. Define Strassens matrix 35. Write formula for Warshalls algorithm 36. Define greedy 37. Define optimal binary search 38. Define adjacency and path matrix 39. Define DP 40. Write Knapsack memory function algorithm 41. Define minimum spanning tree 42. What is numeric problem? 43. Divide conquer method of merge sort 44. Analyze one recursive problem 45. In order output and Post order output of this graph

46. Output of post-order of binary tree is GBQACKFPDERH draw the tree 47. Write the adjacency matrix of the following graph 48. Define path and cycle 49. What is combinatorial problem? 50. DC for merge sort 51. Analyze any one recursive problem 52. What are the characteristics of an algorithm? 53. Define the lower bound and upper bound of an algorithm. 54. Brief about the best case situation of an algorithm with an example. 55. Compare feasible solution and optimal solution. 56. Define the principle of optimality in Dynamic Programming. 57. Brief about recursive algorithm? 58. Explain the space complexity of an algorithm. 59. Brief about worst case situation of an algorithm with an example. 60. Brief about combinatorial problem 61. Write short notes about Greedy Method.

Section B

Explain optimal binary search with an example Explain Hamiltonian cycle with an example (7 Marks)

(7 Marks)

Let G = (V,E) be a connected graph with n vertices. Hamiltonian cycle is a round trip path along n edges of G that visits every vertex once and returns to its starting position. The graph may be directed or undirected, only distinct cycles are output. Algorithm Hamiltonian(k)

{ repeat { NextValue(k) If(x[k] = 0) then return If(k=n) then write(x[1:n]); Else Hamiltonian(k+1) }until(false) } Algorithm NextValue(k) { Repeat { x[k] = (x[k]+1) mod(n+1) if (x[k] = 0) then Return if (Gx[[k-1+, x*k++ 0) then { for j = 1 to k-1 do if(x[j]= x[k]) then break if(j=k) then if((k<n) or (( k=n) and G* x*n+, x*1++0)) then return } }until (false) }

3. Explain the Assignment problem of Branch and Bound with an example 4. Explain the travelling salesman problem in Branch and Bound. 5. Explain the sum of subset problem.

6. Write and explain Warshalls and Floyds algorithm. 7. Write and explain the N-queens algorithm 8. Explain about backtracking. 9. Explain about Branch and Bound 10. Explain about backtracking and compare it with branch and bound. 11. Explain branch and bound, and compare it with backtracking. 12. Explain memory function and memory bound function. 13.Apply Warshalls algorithm define by the following adjacency matrix

0 1 1 1 0 0 0 1 0 1 0 1 0 0 1 0

a 2 b

3 6 1 c

Let n = 4 p(1:3) = (3,3,1) Q(0:3) = (2,3,1,1)

17.Write an algorithm and find the optimal solution to the Knapsack Problem instance n=7, m=15

(p1,p2, p7) = (10,5,15,7,6,18,3) (w1,w2,;;;w7)= (2,3,5,7,1,4,1)

18.Apply bottom up Dynamic programming algorithm to the following instance of knapsack problem

Capacity W = 6 Item 1 2 3 4 5 Weight 3 2 1 4 5 Value 25 20 15 40 50

19.Apply quick sort to the list. Write an algorithm in DC method 20.Write an algorithm for merge sort 21.Write an algorithm and in-order iteration for the following binary tree 22.Write Binary search algorithm using divide and conquer method 23.Explain in detail about Greedy Method with an example.

25.Explain PUSHING and POPING a value into queue with an example. 26.Explain post-order tree traversal.

27.Explain pre-order tree traversal with an example. 28.Describe post-order tree traversal with an example. 29.Explain quick sort algorithm with an example. 30.Explain quick sort algorithm for the sequence of values 44 33 11 55 77 40 50 79 12 98 66

31.Explain the algorithm for insertion sort to the following sequence of values 40,70,50,60,80.

33. Write and iterate the algorithm for max-min to the following sequence of values 34,37,44,49,58,75,25,20 34.Describe asymptotic notation and explain any two problem solving methods.

## Molto più che documenti.

Scopri tutto ciò che Scribd ha da offrire, inclusi libri e audiolibri dei maggiori editori.

Annulla in qualsiasi momento.