P. 1
Analysis And Design Of Algorithms (ADA) 2 marks question

Analysis And Design Of Algorithms (ADA) 2 marks question

|Views: 2,160|Likes:
Published by Adarsh Gumashta

More info:

Published by: Adarsh Gumashta on Aug 01, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less






1. Define Algorithm. An algorithm is a sequence of unambiguous instructions for solving a problem, which means to obtain a required output for any legitimate input in a finite amount of time. 2. What are the characteristics of an algorithm? • Simplicity • Generality • Definiteness • Finiteness • Effectiveness 3. What are three parts of algorithm? • Pre Condition • Body of Algorithm • Post Condition 4. What are the criteria used to identify the best algorithm? • Order Of Growth • Time Complexity • Space Complexity 5. Define time and space complexity. Time Complexity indicates how fast an algorithm runs. T(P)=Compile Time+ Run Time .(Tp) Where Tp is no of add, sub, mul... Space Complexity indicates how much extra memory the algorithm needs. Basically it has three components. They are instruction space, data space and environment space. 6. Difference between Compile and Running Time. Compile Time Running Time 1)"Compile time" can also refer to the amount of time required for compilation. 2) The operations performed at compile time usually include syntax analysis, various kinds of semantic analysis and code generation 3) Compile time occurs before link time (when the output of one or more compiled files are joined together) and runtime 1)“Running Time” can refer to the time required for executing the program 2)Type checking, storage allocation, and even code generation and code optimization may be done at compile-time or upon a run-time, depending on the language and compiler. 3) Running time occurs after compile time.



7. Find the time complexity for summation of N numbers. The time complexity for summation of N numbers is O (N). 8. What are the various types of time complexity of an algorithm? • • • • • Big Oh Big Omega Big Theta Little Oh Little Omega

9. Difference between Best Case and Worst Case Complexities. The best case complexity of an algorithm is its efficiency for the best case input of size N, which is an input of size N for which the algorithm runs fastest among all possible inputs of that size. The worst case complexity of an algorithm is its efficiency for the worst case input of size N, which is an input of size N for which the algorithm runs longest among all possible inputs of that size. 10. What is the Space Complexity for the following algorithm? Void N() { Int P,A,B,C; P=A+B-C; Printf(“%D”,P); } Space Complexity = Space Needed For P,A,B,C = 8 11. Define asymptotic notation. The efficiency analysis framework concentrates on the order of growth of an algorithm’s basic operation count as the principle indicator of the algorithm’s Efficiency. To compare and rank such orders of growth scientists’ use three notations (Big Oh, Big Omega, and Big Theta, which is called as asymptotic notation.

12. What are the 3 standard notations? a) Big Oh(O) b) Big Omega(Ω) c) Big Theta( )



G (N) For All N>=N0 14. ie. What are all the types of recurrence relation? • • • Geometric sequence Arithmetic sequence Linear sequence DAA TWO MARK QUESTION AND ANSWER 3 . Such equations are called recurrence relation. 15. If T(N) Θ (F(N)) For Values Of N That Are Powers Of B.. Define Conditional Asymptotic Notation. The equation defines M (N) not explicitly. 18. What Are The Common Running Time For Big-Oh.denoted T(N)€ O(G(N)). Then T (N) Θ (F(N)) For Any N. Define Recurrence Relation. A function T(N) is said to be in O(G(N)). is a function of n. if there exists some positive constant C and some non negative integer N0 such that T (N) <= C. Define Smoothness Rule. namely N-1.N (C > 0 Vn (N ≥ N N X T(N) ≤ C* F(N) T(N) ≥ 0))}. The function O(F|X) yields a non empty set of functions from N to R and is defined as follows: O(F|X) = {T. 16. F(N) is called Smooth If it is eventually non decreasing and F(2n) Θ (F(N)). T Ranges Over Elements Of RN: Vc. Let T(N) be an eventually a non decreasing function and F(N) be a smooth function. Let F be an eventually nonnegative sequence of real numbers and Let X be a set. Let F (N) be a nonnegative function defined on the set of natural numbers. Define Big-Oh. If T(N) is bounded above by some constant multiple of G(N) for all large N.C>1 17.13.. The common running time for Big-Oh Are • O(N) • O(Log N) • O(N Log N) • O(N^C). Where B>=2. but implicitly as a function of its value at another point.

for the number of times basic operation is executed. is read as "f(x) is little-o of g(x)". the worst case. 23. and if necessary. Identify the algorithms Basic Operation Check whether the number of times the basic operation is executed only on the size of an input. In computer science. Intuitively. f(n) and g(n). It assumes that f and g are both functions of one variable. Define Little Oh and Little Omega Notations.19. If f(n)ε O(n^d) where d ≥ 0. best case efficiencies have to be investigated separately. Define Linear Search. which consists in checking every one of its elements. Worst and Average Case complexity of Linear Search? • • • Best Case – O(1) Average Case – O(N) Worst Case – O(N) 21. one at a time and in sequence. Set up a recurrence relation. • DAA TWO MARK QUESTION AND ANSWER 4 . average case. f(n) is little omega of g(n) if and only if f(n) = Ω(g(n)). it means that The relation g(x) grows much faster than f(x). Define Substitution Method. c > 0. Give Master Theorem. with an appropriate initial condition. What are the Best. If it also depends on some additional property. This is denoted as "f (n) = ω (g (n))". it states For non-negative functions. but f(n) ≠ Θ(g(n)). then O(n^d) if a < b^d T(n) = O(n^d log n) if a = b^d O(n^logb a) if a > b^d 24. Substitution method is a method of solving a system of equations wherein one of the equations is solved for one variable in terms of the other variables. Give the general plan for analyzing recursive algorithm. 20. 22. Let T(n) be a monotonically increasing function that satisfies T(n) = aT(n/b ) + f(n) T(1) = c where a ≥ 1. Formally. linear search or sequential search is a method for finding a particular value in a list. until the desired one is found. • • • Decide a parameter indicating an Input’s Size. b ≥ 2.

• • • Decide a parameter indicating an Input’s Size. If it also depends on some additional property. • • • • • • • Sorting Searching String Processing Graph Problem Combinational Problem Geometric Problem Numerical Problem 31. What are all the methods available for solving recurrence relations? • • • • Forward Substitution Backward Substitution Smoothness Rule Master Theorem 30. What are the types of recurrence relations? • • Homogeneous recurrence relation. Instruction Space and Environment Space. For example. 100n and n + 1 belong to the same order of growth. 34. the worst case. Using standard formulas and rules of sum manipulation either find a closed formula for the count or. Instruction Space: The space needed to store the compiled version of all program instruction Environment Space: The environment stack is used to save information needed to resume execution of partially completed functions. which is written O(n) in “Big-Oh notation” and often called “linear” because every function in the set grows linearly with n. An order of growth of an algorithm is a set of functions whose asymptotic growth behavior is considered equivalent to the given algorithm.25. 29. Define Order Of Growth. 2n. Give the general plan for analyzing non recursive algorithm. DAA TWO MARK QUESTION AND ANSWER 5 . establish its order of growth. • 27. Non homogeneous recurrence relation. average case. Define Data Space. Each time a function is invoked the following data are saved the environment stack. o The return address. at the very least. and if necessary. o The values of all local variables. • • • Data Space: The space needed to store all constants and variable values. Write down the problem types. Identify the algorithms Basic Operation Check whether the number of times the basic operation is executed only on the size of an input. best case efficiencies have to be investigated separately.

Define a knapsack problem. determine the number of each item to include in a collection so that the total weight is less than a given limit and the total value is as large as possible. 7. The solutions to the sub-problems are then combined to give a solution to the original problem. 3. until these become simple enough to be solved directly. find a solution in the feasible region which has the minimum (or maximum) value of the objective function. What is the order of an algorithm? A standard notation used to represent the computing time of the algorithm is termed as the order of an algorithm and is denoted by O. The knapsack problem or rucksack problem is a problem in combinatorial optimization: Given a set of items. 5. The number of comparisons made by the sequential search in the worst and best case are one and n key comparisons respectively. More formally. A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type. DAA TWO MARK QUESTION AND ANSWER 6 . 8. Give some examples of divide and conquer method. 6. each with a weight and a value. What is meant by optimal solution? A solution to an optimization problem which minimizes (or maximizes) the objective function is termed as an optimal solution. CooleyTukey fast Fourier transform (FFT) algorithm and merge sort algorithm. It derives its name from the problem faced by someone who is constrained by a fixed-size knapsack and must fill it with the most useful items. What are the objectives of sorting algorithms? The objective of the sorting algorithm is to rearrange the records so that their keys are ordered according to some well-defined ordering rule. An optimization problem is a computational problem in which the object is to find the best of all possible solutions. Divide and conquer (D&C) is an important algorithm design paradigm based on multibranched recursion. Define divide and conquer strategy. Some of the examples of D&C method are binary search. Euclidean algorithm. 2. Find the number of comparisons made by the sequential search in the worst case and the best case.UNIT 2 1.

so the number of element comparisons is 2(n-1). so the number of element comparisons is nWorst case occurs when the elements are in decreasing order.Q) Combine (D&C(P. do a binary search on the first half. Average case occurs when a[i] is greater than max half the time. D&C(M+1. Binary search is a fast way to search a sorted array. this type of algorithm is known as control abstract algorithms as they give an abstract flow. Write control abstraction for D&C technique. What is the time complexity of straight forward with D & C of finding Min-max? • • • Best case occurs when the elements are in increasing order. What are all the advantages of Binary search? The Binary search is an optimal searching algorithm using us can search the desired element effectively. The idea is to look at the element in the middle. do a binary search of the second half. Applications: The binary search is an efficient searching method & is used to search desired record from database.Q) is small Then Solve(P. DAA TWO MARK QUESTION AND ANSWER 7 . the search is finished. If the key is equal to that. selection and searching algorithm.M). If the key is less than the middle element. Advantages of binary search.Q) Else M ¬ divide(P. 12. For solving nonlinear equations with one unknown this method is used. The control abstraction for D&C technique is as follows: Procedure D&C (P. If it's greater.Q)) } Sometimes. This way of breaking down the problem has found wide application in sorting. What is the time complexity of binary search? Best Case O(1) Average Case O(log2n) Worst Case O(log2n) 13.9. 10. 11.Q) //the data size is from p to q { If size(P.

etc. 15. counting problems. An optimal solution is a feasible solution that optimizes the objective/optimization function. finding an optimal solution is computationally hard. Union ()-is the function that combines x with the solution and updates the objective function. quantum Turing machines. Bipartite cover Single-source shortest paths Minimum-cost spanning trees DAA TWO MARK QUESTION AND ANSWER 8 . complexity classes can be defined based on function problems. Topological sorting. optimization problems. • • • A complexity class is a set of problems of related complexity. However. Define greedy technique: The greedy method is the most straight forward design technique that can be applied to a wide variety of problems. "logarithmic space". Knapsack problem. 17. In general. • 21. 18. The model of computation: The most common model of computation is the deterministic Turing machine. Boolean circuits. Define optimal solution. What is the Control abstraction of greedy technique? • • • Select ()-is the function that selects an input from a [] and removes it. Feasible ()-is a Boolean-valued function that determines whether x can be included into the solution vector. Application of greedy algorithm: • • • • • • Container loading. 19. etc.14. Define Complexity Analysis. The resources (or resources) that are being bounded and the bounds: These two properties are usually stated together. such as "polynomial time". "constant depth". but many complexity classes are based on nondeterministic Turing machines. A feasible solution is a solution that satisfies the constraints 16. promise problems. Define feasible solution. What is meant by Container-loading? Container-loading problem is a problem which is used to load the ship with the maximum number of containers. Simpler complexity classes are defined by the following factors: The type of computational problem: The most commonly used problems are decision problems. monotone circuits. etc.

DYNAMIC PROGRAMMING 1. 23. GA computes the solution in bottom up technique. Follows bottom up technique.22. How the choices are made in each step in greedy method: • • • Choices of solution made at each step of problem solving in greedy approach is as follows. 3. It uses the principle of optimality. Locally optimal-among all feasible solutions the best choice is to be made Irrevocable-once the particular choice is made then it should not get changed on subsequent steps. Feasible-it should the problem's constraints. Each problem is independent.. 4. What is the difference between dynamic programming and divide and conquer? DIVIDE AND CONQUER 1. It computes the solution from smaller sub-routines and tries many possibilities and choices before it arrives at the optimal set of choices. What is the difference between dynamic programming and greedy algorithm? GREEDY ALGORITHM 1. DAA TWO MARK QUESTION AND ANSWER 9 . DA computes its solution by making its choices in a serial fashion (never look backirrevocable). 2. UNIT 3 1.e. Many decisions and sequences are guaranteed and all the overlapping subinstances are considered. It does not use the principle of optimality. 2. Follows top down technique. Find the individual solutions and combine them to get the solution for the main problem. Sub-problems are dependent on the main problem. DYNAMIC PROGRAMMING 1. 2. 2. 2. 4. Split the input at every possible points rather than at a particular point. General plan for divide & conquer algorithm: • • • Divide the problem into two or smaller sub problems Conquer the sub problems by solving them recursively Combine the solutions to the sub problems into the solutions for the original problem.. i. Divide the given problem into many subproblems. there is no test by which one can tell GA will lead to an optimal solution. 3. Split the input only at specific points (mid point).

where the solution to the main problem can be viewed as the result of a sequence of decisions. then a is in Vi . What is dynamic programming? Dynamic programming is an algorithm design method. 8. It states that in an optimal sequence of decisions. Define the principle of optimality. Define multi stage graph. We can either build up solutions of sub-problems from small to large (bottom up) or we can save results of solutions of sub-problems in a table (top down + memorization).3. and | V1 | = | VK | = 1. The cost of a path from node v to node w is sum of the costs of edges in the path. What are the basic elements of dynamic programming? • • • Sub structure Table structure Bottom up computations. by keeping the table of known results of sub-problems. To use dynamic programming the problem must observe the principle of optimality that whatever the initial state is. G is usually assumed to be a weighted graph. and b is in Vi+1 for some subsets in the partition.b) is in E. the vertex t in VK is called the sink. each sub sequence must be optimal. A multistage graph is a graph o o G=(V.This forms the table structure. table structure and bottom up computations. The vertex s in V1 is called the source. 5. DAA TWO MARK QUESTION AND ANSWER 10 . It avoids the calculation of same stuff twice. Define sub structure. 6. A problem is said to have optimal substructure if the globally optimal solution can be constructed from locally optimal solutions to sub problems. remaining decisions must be optimal with regard the state following from the first decision.E) with V partitioned into K >= 2 disjoint subsets such that if (a. Each set Vi is called a stage in the graph. 4. What are the applications of dynamic programming? • • • • • Fibonacci numbers Longest increasing sequence Minimum weight triangulation The partition problem Appropriate string matching 7. The "multistage graph problem" is to find the minimum cost path from s to t.

An OBST is a BST which has minimal expected cost.j)=c(j. for k<--1 to n do for i<--1 to n do for j<--1 to n do D[i. <j.k]+D[k.9.j].j)+cost(i+1.j)=min{c(i.j>Є E since.j]} RUNNING TIME OF THE ALGORITHM: O(n^3) 11) Define OBST.t). Example: Key -5 Probabilities 1 1/8 8 1/32 7 1/16 13 1/32 21 1/4 The expectation-value of a search is: $ E[cost]=1.j) if <1.t> ≤ E and cost (k-1.j]=min{[i. Forward approach Cost(i. <l. cost (k-1.j)= ∞. if<I.l)} l Є vi+1 (vertex in next stage) .j> !Є E 10) Derive the formula for the Floyd’s algorithm and running time of the algorithm.l> Є E.D[i.t> !Є E Backward approach Bcost(i. (1/32+1/4)+3.j)= ∞ if<1.l)+c(l.j)} l Є vi-1 .j) of multistage graph in both forward and backward approach. if <j.j> Є E and bcost(2.j)=min{bcost(i-1.1/16+2.(1/8+1/32+1/2) DAA TWO MARK QUESTION AND ANSWER 11 . Give the formula for cost (i. Since.j)=c(1.bcost(2.

The most common formulation of the problem is the 0-1 knapsack problem.It's clear that this tree is not optimal. It is one of the most intensively studied problems in optimization. the left and the right.No: 195 17) Define 0/1 Knapsack problem. Criterion for an optimal tree: Each optimal binary search tree is composed of a root and (at most) two optimal sub trees. the tree will have a lower expected cost. . 13) What is the running time of traveling salesman problem and 0/1 knapsack problem? TSP: 0(n^2 * 2^n) 0/1 Knapsack: 0(nw) 14) What is meant by TSP? The Traveling Salesman Problem (TSP) is a problem in combinatorial optimization studied in operations research and theoretical computer science. The root value is given by R [1. Given a list of cities and their pair wise distances. The k values the entries in the main table is entered into the root table. 16) Write down the formula for the expected cost of the binary search tree.It is easy to see that if the 21 is closer to the root. n]. NOTE: Draw the graph given in class notes. 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: DAA TWO MARK QUESTION AND ANSWER 12 . Refer Ellis horrowitz textbook Pg. 12) What is root table? The root table is a table which has 0 to n columns and 1 to n+ 1 row. the task is to find a shortest possible tour that visits each city exactly once. given its high probability. 15) What are the preconditions for the Floyd’s algorithm? The precondition for the Floyd’s algorithm is that the graph should not have a cycle of negative length or cost.

. Develop a recurrence relation that is a solution to its sub solution using mathematical notation in step 1. Backtracking is to build up the solution vector one component at a time and to use modified criterion function Pi(x1. Write an algorithm to compute the recurrence relation. Difference between Backtracking & Exhaustive search. Backtracking Exhaustive search 1..xi) (sometimes called bounding function) to test whether the vector being formed has any chance of success.. Prove the principle of optimality.x2. It suggests generating each and every element of the problem’s domain.18) What are the steps involved in dynamic programming? • • • • Develop a mathematical relation that can express any solution and sub solutions for problem. and then finding a desired element..xi) can in no way lead to an optimum solution.” DAA TWO MARK QUESTION AND ANSWER 13 . UNIT 4 1.. 2. m=m1m2. Backtracking is to build up the solution vector one component at a time and to use modified criterion function Pi(x1.. selecting those of them that satisfy the problem’s constraints.. It suggests generating each and every element of the problem’s domain. however applicable for small instances of problems.xn) where xi are chosen from some set Si. Define Backtracking.. 3. Desired solution expressed as an ntuple (x1. Define exhaustive search. Exhaustive search is impractical for large instances. Exhaustive search is simply a “brute – force” approach to combinatorial problems. • • • If |Si|=mi.xi) (sometimes called bounding function) to test whether the vector being formed has any chance of success.. and then finding a desired element.mn candidates are possible Yielding the same answer with far fewer than m trials Advantage : if it is realized that the partial vector (x1.…. Exhaustive search is simply a “brute – force” approach to combinatorial problems. selecting those of them that satisfy the problem’s constraints. 2. Backtracking makes it possible to solve many large instances of NP-hard problems in an acceptable amount of time. then mi+1…mn possible test vectors can be ignored entirely..

or Si = {all nonnegative real numbers} xi = {0. • • • Explicit constraints depend on the particular instance I of problem being solved All tuples that satisfy the explicit constraints define a possible solution space for I Examples of explicit constraints xi >= 0. • • • Decision’s problem: . Enumeration problem: . 7. List down the examples of backtracking. How can you represent the solution for 2 queen’s problem? There is no solution for 2 Queen’s problem since however the queens are arranged both queens would be in same diagonal or column. Define explicit constraint.Finds all possible feasible solution. Define promising and non promising node. Optimization problem: . • • • • n-Queens problem Hamiltonian circuit problem Subset-Sum problem constraint satisfaction problem 6. 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.Whether there exists any best solution. 1 } li <= xi <= ui or Si = {a : li ≤ a ≤ ui } 10.4. • • Implicit constraints are rules that determine which of the tuples in the solution space of I that satisfy the criterion function.Whether there is any feasible solution. • 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. DAA TWO MARK QUESTION AND ANSWER 14 . 5. Explicit constraints are rules that restrict each xi to take on values only from a given set. Give the categories of the problem in backtracking. What are the two types of constraints used in Backtracking? • • Explicit constraints Implicit constraints • 8. 9. Implicit constraints describe the way in which the x is must relate to each other. Define implicit constraint. 1} or Si = { 0.

Define solution states and answer state? Solution state: • • • Solution states are the problem states s for which the path from the root node to‘s’ defines a tuple in the solution space In variable tuple size formulation tree. 7) – The solution vectors can also be represented by the indices of the numbers as (1.…. Constraints are. solution space reduced from 88 to 8!) o No two queens can be on the same diagonal 12. 2 . Explicit constraints o Si={1.2. 2. Define n-queens problem Place n queens on an n × n chessboard so that no queen attacks another queen which means no two queen’s are in same row/column or same diagonal Solution space consists of all n! Permutations of the n-tuple (1. 7).8} Implicit constraints o No two xi’s can be the same column or row (By this.…. 13. Define sum of subsets problem? In the Sum-of-Subsets problem. For example. 24. 4) and (3. n) 13. x2.11. . 13. 7) and (24. x8) where xi is the column on which queen “i” is placed. w = (11. The goal is to find all subsets of the integers that sum to W. all nodes are solution states In fixed tuple size formulation tree. only the leaf nodes are solution states DAA TWO MARK QUESTION AND ANSWER 15 . Define state space of the problem? • State space is the set of all paths from root node to other nodes 16. 1 <= k <= n 14. and m = 31. the desired subsets are (11. Define problem state? • Problem state is each node in the depth-first search tree 15. there are n positive integers (weights) wi and a positive integer W. 4) _ All solutions are k-tuples. n = 4. . How can you represent the solution for 8 queen’s problem? All solutions represented as 8-tuples (x1.

Define m color ability decision problem. Static trees are ones for which tree organizations are independent of the problem instance being solved • • Fixed tuple size formulation Tree organization is independent of the problem instance being solved 19. • • Live node is a generated node for which all of the children have not been generated yet E-node is a live node whose children are currently being generated or explored. Define static tree. Define live node. DAA TWO MARK QUESTION AND ANSWER 16 . This integer is referred to as the chromatic number of the graph. 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. Define dynamic tree. Let G be a graph and m be a given positive integer. If d is the degree of the given graph. Define state space tree? • State space tree is the tree organization of the solution space 18. If three colors are needed to color the graph then the graphs chromatic number is 3. Dead node is a generated node that is not to be expanded any further • • All the children of a dead node are already generated Live nodes are killed using a bounding function to make them dead nodes 22. • Dynamic trees are ones for which organization is dependent on problem instance 20. The color of each node is indicated next to it. This is termed the m-colorability decision problem. then it can be colored with d+ 1 color.• Partitioned into disjoint sub-solution spaces at each internal node Answer state: • • Answer states are that solution states s for which the path from root node to s defines a tuple that is a member of the set of solutions These states satisfy implicit constraints 17. The m-colorability optimization problem asks for the smallest integer m for which the graph G can be colored. Define dead node. 21.

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. Define graph traversal. Mention the types of traversal. Define Hamiltonian circuit problem. What is the time complexity of BFS? • • If the graph is represented by adjacency matrix: O (n2 ). Moreover. if the last vertex of the path duplicates the first one without ever repeating any other vertex in between. What is meant by BFS traversal? • • • • It starts from the arbitrary vertex. v2.l) The equation to represent 2 queens are in same diagonal is i+j=k+l i-j=k-l j-l=k-I j-l=i-k or Unit 5 1. 3.23.j) and (k. . State the equation which is used to represent 2 queens are in same diagonal. The exploration of the vertex V is suspended as soon as a new vertex is reached At this time the exploration of new vertex U begins The new vertex is explored the exploration of V continues The search terminates when all reached vertices have been fully explored. This process is repeated until no more vertexes is left 4. vn is a Hamiltonian path if every vertex of the graph occurs exactly once in this path. 2. Define depth first search traversal. Then it visits next unvisited vertex. • • Breath first search traversal. Let the diagonals be (i. . If the graph is represented by adjacency List: O (|V|+ |E| ). We say that a path v1. Depth first search traversal. then the path is called a Hamiltonian circuit 24. 5. • • • • • It starts from the arbitrary vertex. It starts at initial vertex and visits each and every vertex exactly once and finally reaches end vertex. It visits all vertices adjacent to starting vertex. Suppose we are given a graph G = (V. DAA TWO MARK QUESTION AND ANSWER 17 .E) that is undirected.

What is meant by articulation point? An articulation point is a vertex v of G such that the deletion of v. produces a graph. If the graph is represented by adjacency List: O (|V|+ |E| ). How do identify connected component using breath first search? • • • BFS can be used to determine whether G is connected Using BFS all newly visited vertices are put on the list.. Compare DFS and BFS. A connected component is the maximal sub graph of a given graph. there is path from U to V. • • A bi connected graph is a connected graph that has no articulation points A bi connected component of a connected undirected graph is a maximal bi connected sub graph of G DAA TWO MARK QUESTION AND ANSWER 18 . together with all edges incident on v. DFS It uses STACK representation It contains tree edge and back edge It used to identify articulation points BFS It uses QUEUE representation It contains tree edge and cross edge It is used to identify minimum edge paths 8.6. Define spanning tree. Sub graph formed by the vertices on this list make up a connected component. and all connected graphs with n -1 edges are trees A spanning tree has n -1 edge 11. 7. G'. Define bi connected graph and bi connected component. 9. of G such that V (G') = V (G) and G' is connected A minimal sub graph is one with the fewest no. G'. of edges Any connected graph with n vertices must have at least n -1edges.. What is the time complexity of DFS? • • If the graph is represented by adjacency matrix: O (n2 ). 10. • • • • A spanning tree is a minimal sub graph. that has at least two connected components 12. Define connected component. • • A graph is said to be connected if for every pair of its vertices U and V.

whenever a new unvisited vertex is reached for the first time. we compute the L(u) that is reachable from V by taking zero or more edges and then possible one back edge. What is tree edge and cross edge? In the breath first search forest. List down the bi connected components for the following connected graph. that is noted as a cross edge. If an edge is leading to a previously visited vertex other than its immediate predecessor. 16. it is attached as a child to the vertex from which it is being reached. Such an edge is called tree edge. What are the methods to identify the articulation point? • • • Common vertex in bi connected component Depth first spanning tree Lowest depth first number 15. Connected graph is 14. DAA TWO MARK QUESTION AND ANSWER 19 .13. What is meant by lowest depth first number? For every vertex V in depth first spanning tree.

an E-node is a node currently being expanded. Examples are Binary search O (log n). and matrix multiplication 0(n 2. What is meant by Least Cost Search? The next E-node is selected on the basis of this ranking function. Define live node. 21. Define branch and bound. In other words. e node and dead node.16. 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. What are the types search strategies • FIFO search • LIFO search • LC search 19. DAA TWO MARK QUESTION AND ANSWER 20 . What is meant by class P (Polynomial)? Class P consists of problems whose solutions are bounded by the polynomial of small degree. • Dead node is a generated node that is not to be expanded or explored any further. • E-node is a live node whose children are currently being explored. Let ˆg(x) be an estimate of the additional effort needed to reach an answer from node x. 17. Heuristic is based on the expected additional computational effort (cost) to reach a solution from the current live node. 22. Compare the FIFO and LIFO search. All children of a dead node have already been expanded. Define intelligent function. 18. sorting O (n log n). 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. in branch and bound? • BFS is an FIFO search in terms of live nodes • List of live nodes is a queue • DFS is an LIFO search in terms of live nodes • List of live nodes is a stack • 20. • Live node is a node that has been generated but whose children have not yet been generated.81).

• • All NP-complete problems are NP-hard – TRUE.. non deterministic algorithm Algorithm contain operation whose out come are not uniquely defined but are limited to specified set of possibilities 26.. Define SATISFIABILITY. _ Let xi denotes the relation of xi. Examples are Traveling salesperson problem O(n22n). Differentiate between the deterministic and non deterministic algorithm. 27. Differentiate between the decision and optimization problem.23. Deterministic algorithm Algorithm contains whose out come are uniquely defined. x3….. A literal is either a variable or its negation. x2. 1 or 0 intended Optimization Problem Computational problem where we try to maximize or minimize the objective function. What are the two classes of non polynomial time problems? • NP. All NP-hard problems are not NP-complete. State true or false. knapsack problem O(2n/2) 24. 28.hard • NP-complete 25. Decision Problem Computational problem with output of yes or no ie. DAA TWO MARK QUESTION AND ANSWER 21 . A formula in the prepositional calculus is an expression that can be constructed using literals and the operators and Λ or v. The satiability problem is to determine if a formula is true for some assignment of truth values to the variables.xn denotes Boolean variables. Let x1.TRUE. What is meant by Class NP (Non Polynomial)? Class P consists of problems whose solutions are bounded by the non polynomial. A clause is a formula with at least one positive literal.

but it is not NP-complete.29. Define COOK’S theorem.Complete: A problem L is NP-complete if and only if L is NP-hard and L є NP. Satisfiability is in P if and only if P = NP. Halting problem is NP-hard decision problem. 30. DAA TWO MARK QUESTION AND ANSWER 22 . What is meant by NP hard and NP complete problem? • • • NP-Hard Problem: A problem L is NP-hard if any only if satisfiability reduces to L. NP. There are NP-hard problems that are not NP-complete.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->