Upcoming SlideShare
×

# QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS

3,079 views

Published on

first of all i am very happy that the only university that keeps its blog updated. the habit of using algorithm analysis to justify design decisions when you write implement new algorithms and to compare the experimental performance .

Published in: Career
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
3,079
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
173
0
Likes
3
Embeds 0
No embeds

No notes for slide

### QUESTION BANK FOR ANNA UNNIVERISTY SYLLABUS

1. 1. Subject Code / Name: CS 2251 Design & Analysis of Algorithm UNIT-I PART-A 1. Define Big ‘Oh’ notation. (AU – 2011, 2012,2013) The Big ‘Oh’ notation provides an upper bound for the function t. A function t(n) is said to be in O(g(n)), if there exist some positive constant C and some non negative number No, such that , t(n)<=Cg(n), for all n>=no. 2. What is meant by linear search? (AU - 2012) ( AU - 2011) Linear search, also known as sequential search, is a process that checks every element in the list sequentially until the desired element is found. The computational complexity for linear search is O(n), making it generally much less efficient than binary search (O(log n)). But when list items can be arranged in order from greatest to least and the probabilities appear as geometric distribution (f (x)=(1-p) x-1p, x=1,2), then linear search can have the potential to be notably faster than binary search. 3. What is the properties of big-Oh notation. ( AU - 2011) The mathematical properties of big oh. In particular, suppose we know that and .  What can we say about the asymptotic behavior of the sum of  What can we say about the asymptotic behavior of the product of  How are and related when and and . . . 4. Using the step count method analyze the time complexity when 2 m × n matrices are added. (AU - 2011) The best-case step count is the minimum number of steps that can be executed for the given parameters. The worst-case step count is the maximum number of steps that can be executed for the given parameters. The average step count is the average number of steps executed instances with the given parameters. 5. What do you mean by an Algorithm? ( AU - 2013) DAA 1 AMBIKA J KINGS COLLEGE ,THANJAVUR
2. 2. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Ans: An algorithm is a finite set of instructions that, if followed, accomplishes a particular task. In addition, all algorithms must satisfy the following criteria: 1) input 2) Output 3) Definiteness 4) Finiteness 5) Effectiveness. 6. What is the explicit formula for the nth Fibonacci number? (AU - 2007) The formula for the nth Fibonacci number is given by T(n)=1/√5фn-1/√5фn 7. Define Algorithm Validation.(AU - 2012) It is the process of computing the correct answer for all possible legal inputs after the algorithm is created or devised. The purpose of the validation is to assure that the algorithm will work correctly independently of the programming languages. Once the validation is done the program can be written and the second phase of the validation, which is referred to as program proving or program verification, begins. 8. What is the Average case complexity of Linear search Algorithm? (AU - 2008) Mathematically, the average case value has stated as A(n) = ∑P(I)T(I) i €Dn 9. Differentiate Time Complexity from Space complexity. (AU - 2010) S.No Time Complexity Space Complexity 1. Time complexity refers to the amount of time spent by the processor for the completion of the task. space complexity refers to the amount of memory occupied by a specific process or task. 2. The total number of steps involved in a solution to solve a problem is the function of the size of the problem, which is the measure of that problem’s time complexity. Quantities to estimate Time complexity estimation is based on execution time Space complexity is measured by using polynomial amounts of memory, with an infinite amount of time. 3. Space complexity estimation is based on memory space 10. What is a Recurrence Equation? (AU - 2010) It can be classified into homogeneous and inhomogeneous in the algebra of mathematics there are easy ways to solve both homogeneous and inhomogeneous. DAA 2 AMBIKA J KINGS COLLEGE ,THANJAVUR
3. 3. Subject Code / Name: CS 2251 Design & Analysis of Algorithm a0xn+a1xn-1+….+akxn-k=0 PART-B 1. Discuss in detail all the asymptotic notations with examples. (8)(AU - 2012) 2. With a suitable example, explain the method of solving recurrence equations. (8)(AU 2012) 3. Define Asymptotic notations. Distinguish between Asymptotic notation and conditional asymptotic notation. (10) ( AU - 2011) 4. Explain how the removing condition is done from the conditional Asymptotic notation with an example. (6) ( AU - 2011) 5. Explain how analysis of linear search is done with a suitable illustration. (10) (AU - 2011) 6. Define recurrence equation and explain how solving recurrence equations are done. (6) (AU - 2011) 7. Write the recursive and non-recursive versions of the factorial function.(8) (AU – 2011) 8. Examine how much time each function requires as ‘n’ becomes large. (8) (AU - 2011) 9. Explain asymptotic notations in detail. (8) (AU - 2011) 10. Write an algorithm for linear search and analyze the algorithm for its time complexity.(8) (AU - 2011) 11. Explain briefly the Time Complexity estimation, space complexity estimation and the tradeoff between Time and Space complexity. (6) (AU - 2010) 12. Write the linear search algorithm and analyze for its best, worst and average case time complexity. (10) (AU - 2010) 13. Prove that for any two functions (n f and ) (n g , we have )) ( ( ) ( n g n f θ = if and only if )) ( ( ) ( n g O n f = and )) ( ( ) n g n f = . (6) (AU - 2010) 14. Explain how Time Complexity is calculated. Give an example. (AU - 2010) 15. Elaborate on Asymptotic Notations with examples. (AU - 2010) UNIT II PART-A 1. What is the drawback of greedy algorithm? (AU - 2012)     Despite their simplicity, correct greedy algorithms can be subtle. o It's easy to fool yourself into believing an incorrect greedy algorithm is correct. o “I can't think of a counter-example, so there are none.” Using greed is not an automatic. It may not be the best solution and sometimes may even be the worst possible one. Greedy algorithms don't work for some problems. 2. What is the time complexity of binary search? (AU - 2012) DAA 3 AMBIKA J KINGS COLLEGE ,THANJAVUR
4. 4. Subject Code / Name: CS 2251 Design & Analysis of Algorithm In conclusion we are now able completely describe the computing time of binary search by giving formulas that describe the best, average and worst cases. Successful searches Best Case-----O(1) Average Case----O(logn) Worst Case-----O(logn) Unsuccessful searches O(logn) best, average, worst 3. What greedy algorithms? ( AU - 2011) A greedy algorithm obtains an optimal solution to a problem by making a sequence of choices. At each decision point, the algorithm chooses the locally optimal solution. In other words, when we are considering which choice to make, we make the choice that looks best in the current situation, without considering results from sub problems. 4. What Knapsack problem? ( AU - 2011) Given n items of known weights w1,w2...........wn and values v1,v2............vn and a knapsack of capacity W, find the most valuable subset of the items that fit into the knapsack.(Assuming all the weights and the knapsack's capacity are positive integers the item values do not have to be integers.) 5. Write the Control abstraction for Divide-and conquer. (AU - 2013) A control abstraction we mean a procedure whose flow of control is clear but whose primary operations are by other procedures whose precise meanings are left undefined. 6. What do you mean by divide and conquer strategy?(AU - 2013) Given a function to compute on ‘n’ inputs the divide-and-comquer strategy suggests splitting the inputs in to’k’ distinct susbsets, 1k n, yielding ‘k’ subproblems. The subproblems must be solved, and then a method must be found to combine subsolutions into a solution of the whole. If the sub problems are still relatively large, then the divideand conquer strategy can possibly be reapplied. 7. State the general principle of greedy algorithm. (AU - 2010) A greedy algorithm obtains an optimal solution to a problem by making a sequence of choices. At each decision point, the algorithm chooses the locally optimal solution. In other words, when we are considering which choice to make, we make the choice that looks best in the current situation, without considering results from sub problems. 8. What is called Substitution Method? (AU - 2010) The substitution method for solving recurrences consists of two steps: 1. Guess the form of the solution. 2. Use mathematical induction to find constants in the form and show that the solution works. DAA 4 AMBIKA J KINGS COLLEGE ,THANJAVUR
5. 5. Subject Code / Name: CS 2251 Design & Analysis of Algorithm The inductive hypothesis is applied to smaller values, similar like recursive calls bring us closer to the base case. The substitution method is powerful to establish lower or upper bounds on a recurrence. 9. List out the drawbacks of the binary search algorithm.(AU - 2007)  Transfer of records from the physical table is very high during insertion and deletion of the record. Binary search is more complex compare to the linear search.  10. What is an Optimal Solution? (AU - 2010) A feasible solution either maximizes or minimizes the given objective function is called as optimal solution. UNIT II PART B 1. Explain divide – and – conquer method with merge sort algorithm. Give an example. (16) (AU - 2012) 2. Write a recursive algorithm to determine the max and min from a given element and explain. Derive the time complexity of this algorithm and compare it with a simple brute force algorithm for finding max and min. (10) (AU - 2010) 3. Write a recursive algorithm to determine the max and min from a given element and explain. Derive the time complexity of this algorithm and compare it with a simple brute force algorithm for finding max and min. (10) (AU - 2010) 4. Explain how greedy method can be applied to solve the Knapsack problem. 5. What is divide and conquer strategy and explain the binary search with suitable example problem. ( AU - 2011) 6. Distinguish between Quick sort and Merge sort, and arrange the following numbers in increasing order using merge sort. (18, 29, 68, 32, 43,37, 87, 24, 47, 50) (AU - 2011) 7. Using the divide and conquer approach to find the maximum and minimum in a set of ‘n’ elements. Also find the recurrence relation for the number of elements compared and solve the same. (16)(AU - 2011) 8. For the following list of elements trace the recursive algorithm for finding max and min and determine how many comparisons have been made.22, 13, –5, –8, 15, 60, 17, 31, 47. (6) (AU - 2010) DAA 5 AMBIKA J KINGS COLLEGE ,THANJAVUR
6. 6. Subject Code / Name: CS 2251 Design & Analysis of Algorithm 9. Write the container loading greedy algorithm and explain. Prove that this algorithm is optimal. (8) (AU - 2010) 10. Suppose you have 6 containers whose weights are 50, 10, 30, 20, 60, 5 and a ship whose capacity is 100. Use the above algorithm to find an optimal solution to this instance of the container loading problem. (8) (AU - 2010) 11. With a suitable algorithm, explain the problem of finding the maximum and minimum items in a set of n elements. (16)(AU - 2010) 12. Explain Merge Sort Problem using divide and conquer technique. Give an example.(16) (AU - 2010) UNIT III PART-A 1. State principle of optimality. (AU - 2012) , (AU - 2010) "An optimal policy has the property that whatever the initial state and initial decision are the remaining decision must constitute an optimal policy with regard to the state resulting from the rest decision." If an optimal state P results in a state Q , this initial state to this final state ,the portion of the original must be optimum. That is every part of optimal policy is optimal. 2. Differentiate greedy method and dynamic programming. (AU - 2012) (AU - 2011) Greedy method: Greedy method focuses on expanding partially constructed solutions. It provides many results such as feasible solution. More efficient Dynamic programming: Focuses on principle of optimality. It provides specific answers. Less efficient 3. What is traveling salesperson problem? (AU - 2011) Let g = (V, E) be a directed. The tour of G is a directed simple cycle that includes every vertex in V. The cost of a tour is the sum of the cost of the edges on the tour. The traveling salesperson problem to find a tour of minimum cost. 4. What do you mean by multistage graphs? (AU - 2011), (AU - 2010) A Multistage graph G= (V,E) is a directed graph in which the vertices are partitioned into k>=2 disjoint sets Vi, 1<i<k. In addition if <u,v> is an edge in E then u belongs to Vi DAA 6 AMBIKA J KINGS COLLEGE ,THANJAVUR
7. 7. Subject Code / Name: CS 2251 Design & Analysis of Algorithm and V belongs to Vi+1 for some I, 1<i<K. The srts V1 and Vk are such that |v1|=|vk| =1. The vertex s is the source and t the sink. 5. How the problems can be solved using Dynamic Programming?( AU - 2005) Condition: An optimal sequence of decisions can be found by making many decisions at a time and all the overlapping sub-instances are considered. 6. Write an algorithm to find the shortest path between all pairs of nodes. (AU - 2011) The shortest path problem can be defined for graphs whether undirected, directed, or mixed. It is defined here for undirected graphs; for directed graphs the definition of path requires that consecutive vertices be connected by an appropriate directed edge. 1. Assign to every node a tentative distance value: 2. Mark all nodes unvisited. Set the initial node as current. Create a set of the unvisited nodes called the unvisited set consisting of all the nodes. 3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances. 4. When we are done considering all of the neighbors of the current node, mark the current node as visited and remove it from the unvisited set. A visited node will never be checked again. 5. If the destination node has been marked visited or if the smallest tentative distance among the nodes in the unvisited set is infinity, then stop. The algorithm has finished. 6. Select the unvisited node that is marked with the smallest tentative distance, and set it as the new "current node" then go back to step 3. 7. Define Multigraph. (AU - 2013) A multigraph G = (V,E,f ) consists of a non-empty set V of vertices (or nodes), a set E (possibly empty) of edges and a function f with domain E and codomain the set of pairs in V.    Undirected multigraph (edges without own identity) Directed multigraph (edges without own identity) Directed multigraph (edges with own identity) 8. Compare divide and conquer with dynamic programming. (AU - 2010) Divide And Conquer: Given a function to compute on ‘n’ inputs the divide-and-conquer strategy suggests splitting the inputs in to ’k’ distinct subsets, yielding ‘k’ sub problems. The sub problems must be solved, and then a method must be found to combine sub solutions into a solution of the whole. If the sub problems are still relatively large, then the divide-and conquer strategy can possibly be reapplied. Dynamic programming: Focuses on principle of optimality. It provides specific answers. Less efficient DAA 7 AMBIKA J KINGS COLLEGE ,THANJAVUR
8. 8. Subject Code / Name: CS 2251 Design & Analysis of Algorithm 9. Define 0/1 knapsack problem.( AU - 2013) 0/1Knapsack Problem •Suppose you are a thief, and you are nowin a jewelry shop (nobody is around !) •You have a big knapsack that you have“borrowed”from some shop before •Weight limit of knapsack:W •There arenitems,I1,I2,...,In Ik has value vk, weight wks Target: Get items with total value as large as possible without exceeding weight limit 10. Define Optimal Binary Search Tree. (AU - 2010) If ‘q’ is always chosen such that ‘aq’ is the middle element (that is, q=[(n+1)/2), then the resulting search algorithm is known as binary search. In conclusion we are now able completely describe the computing time of binary search by giving formulas that describe the best, average and worst cases. UNIT III PART-B 1. With a suitable example, explain all – pair shortest paths problem. (AU - 2012) 2. How is dynamic programming applied to solve the traveling salesperson problem? Explain in detail with an example. (AU - 2012) 3. Explain the multistage graph problem with an example. (8) (AU - 2011) 4. Find an optimal solution to the knapsack instance n = 7, m= 15 (p1, p2, p3, ….p7) = (10, 5, 15, 7, 6, 18, 3) and (w1, w2, w3, ... w7) (2, 3, 5, 7, 1, 4, 1) (8) (AU - 2011) 5. Describe binary search tree with three traversal patterns? Give suitable example with neat diagram for all three traversal of binary search tree.(16) (AU - 2011) 6. Use function OBST to compute w(i, j), r(i, j), and c(i, j), 0<=i<j<=4, for the identifier set ( ) 4 3 2 1 , , , a a a a = (cout, float, if, while) with p(1) = 1/20, p(2) = 1/5, p(3) = 1/10, p(4) = 1/20, q(0) = 1/5, q(1) = 1/10, q(2) = 1/5, q(3) = 1/20, and q(4) 1/20. Using the r(i, j)’s, construct the optimal binary search tree.(16) (AU - 2011) 7. Using dynamic approach programming, solve the following graph using the backward approach. (16)( AU - 2011) 8. Write and explain the algorithm to compute the all pairs source shortest path using dynamic programming and prove that it is optimal (8) (AU - 2010) 9. For the following graph having four nodes represented by the matrix given below determine the all pairs source shortest path (8) (AU - 2010) 10. Write the algorithm to compute the 0/1 knapsack problem using dynamic programming and explain it. (8) (AU - 2010) 11. Solve the following instance of the 0/1, knapsack problem given the knapsack capacity is W = 5 (8) (AU - 2010) DAA 8 AMBIKA J KINGS COLLEGE ,THANJAVUR
9. 9. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Items Weight Value 1 2 12 2 1 10 3 3 20 4 2 15 132 132 132 53099 3 12. Write down and explain the algorithm to solve all pairs shortest paths problem. (16) (AU - 2010) 13. Explain how dynamic programming is applied to solve travelling salesperson problem.(16)( AU - 2010) UNIT IV PART-A 1. What is graph cloning? ( AU- 2011) Cloning means to duplicate a graph along with data tables and results included on that graph. Enter a new data set, and it will instantly be graphed the same way. 2. Define the chromatic number of a graph. (AU- 2011) A coloring using at most k colors is called a (proper) k-coloring. The smallest number of colors needed to color a graph G is called its chromatic number, and is often denoted χ(G). Sometimes γ(G) is used, since χ(G) is also used to denote the Euler characteristic of a graph. A graph that can be assigned a (proper) k-coloring is k-colorable, and it is k-chromatic if its chromatic number is exactly k. A subset of vertices assigned to the same color is called a color class, every such class forms an independent set. 3. Draw a graph with a cycle but with no Hamiltonian cycle. (AU- 2011) 4. State if backtracking always produces optimal solution.(AU – 2008) DAA 9 AMBIKA J KINGS COLLEGE ,THANJAVUR
10. 10. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Backtracking always produces optimal solution since backtracking is a systematic way to go through all the possible configuration of a solution space for the problem instances. 5. Define sum of subset problem. (AU-2013) The subset sum problem is a good introduction to the NP-complete class of problems. There are two reasons for this It is a decision and not an optimization problem.  It has a very simple formal definition and problem statement.  6. Explain the idea behind backtracking. (AU-2010,2011,2012) Backtracking is a technique used to solve problems with a large search space, that Systematically tries and eliminates possibilities. A standard example of backtracking would be going through a maze. At some point in a maze, you might have two options of which direction to go: Junction ------------------------ Portion A | Portion B 7. Define and solve the graph coloring problem. (AU - 2010) The Graph coloring problem asks us to assign the smallest number of colors to vertices of a graph so that no two adjacent vertices are the same color. 8. Define Hamiltonian Cycle. (AU - 2013) A Hamiltonian cycle, also called a Hamiltonian circuit, Hamilton cycle, or Hamilton circuit, is a graph cycle (i.e., closed loop) through a graph that visits each node exactly once (except for the vertex that is both the start and end, which is visited twice). A graph that contains a Hamiltonian cycle is called a Hamiltonian graph. The problem of finding a Hamiltonian cycle or path in a graph is a special case of the traveling salesman problem. 9. Differentiate Explicit and Implicit Constraints. (AU – 2010, 2012) 1) Explicit constraints: Explicit constraints are rules that restrict each Xi to take values only from a given set. Some examples are, Xi  0 or Si = {all non-negative real nos.} Xi =0 or 1 or Si={0,1}. Li  Xi  Ui or Si= {a: Li  a  Ui}  All tupules that satisfy the explicit constraint define a possible solution space for I. 2) Implicit constraints: DAA 10 AMBIKA J KINGS COLLEGE ,THANJAVUR
11. 11. Subject Code / Name: CS 2251 Design & Analysis of Algorithm The implicit constraint determines which of the tuples in the solution space I can actually satisfy the criterion functions. 10. What is the difference between a Live Node and a Dead Node? (AU - 2010) A node which has been generated and all of whose children have not yet been generated is called as a live node. Dead node is defined as a generated node, which is to be expanded further all of whose children have been generated. UNIT IV PART-B 1. Explain the algorithm for finding all m-colorings of a graph. (8) (AU - 2012) 2. Explain elaborately recursive backtracking algorithm? ( AU - 2011) (8) 3. What is Hamiltonian problem? Explain with an example using backtracking. (16) ( AU - 2011) 4. Write down and explain the procedure for tackling the 8 – queens problem using a backtracking approach.(8) (AU - 2012) 5. How does backtracking work on the 8 Queens problem with suitable example? (8) ( AU - 2011) 6. Using backtracking, find the optimal solution to a knapsack problem for the knapsack instance n = 8, m = 110, (p1, p2. ... p7) = (11, 21, 31, 33, 43, 53, 55, 65) and (w1, w2,...,w7) = (1, 11, 21, 33, 43, 53, 55, 65). ( AU - 2011) 7. Write an algorithm for N QUEENS Problem and Trace it for n=6. (AU - 2011) 8. Write an algorithm to determine the Sum of Subsets for a given Sum and a Set of numbers. Draw the tree representation to solve the subset sum problem given the numbers set as {3, 5, 6, 7, 2} with the Sum = 15. Derive all the subsets. (8 + 8) (AU 2010) 9. Write an algorithm to determine Hamiltonian cycle in a given graph using back tracking. For the following graph determine the Hamiltonian cycle. (8 + 8) (AU 2010) 10. Describe the backtracking solution to solve 8-Queens problem. (AU - 2010) 11. With DAA 11 an example, explain Graph Coloring Algorithm. (AU-2010) AMBIKA J KINGS COLLEGE ,THANJAVUR
12. 12. Subject Code / Name: CS 2251 Design & Analysis of Algorithm UNIT V PART-A 1. What is an articulation point in a graph? (AU- 2012) A vertex of a connected graph G is said to be in articulation point, if its removal with all edges incident to it breaks the graph into disjoint pieces. An Articulation point in a connected graph is a vertex that, if delete, would break the graph into two or more pieces (connected component). Articulation points: A, H, G, J 2. What is the difference between BFS and DFS methods? (AU- 2012) S.No DFS BFS 1. A depth first A breadth first traversal would visit traversal would the nodes in this visit the node in order this order A, B, D, C, E, F A / B C / / D E F 2. Notice that you go all the way down one leg before moving on. A, B, C, D, E, F A / B C / / D E F Here we work all the way across each level before going down. 3. Depth first use a Breadth-first use a stack. (The recursive queue. implementation uses the call-stack...) 3. What is spanning tree? Give an example. (AU2010,2011) A minimum spanning tree (MST) or minimum weight spanning tree is then a spanning tree with weight DAA 12 AMBIKA J KINGS COLLEGE ,THANJAVUR
13. 13. Subject Code / Name: CS 2251 Design & Analysis of Algorithm less than or equal to the weight of every other spanning tree. More generally, any undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of minimum spanning trees for its connected components. 4. What is NP Completeness? (AU - 2011) In computational complexity theory, the complexity complete(abbreviated NP-C or NPC) is a class of decision problems. A decision problem 1. 2. class NP- is NP-complete if: is in NP, and Every problem in NP is reducible to in polynomial time. can be shown to be in NP by demonstrating that a candidate solution to in polynomial time. can be verified 5. Define a strongly connected digraph and give the minimum in degree of all the nodes in the graph. (AU- 2011) If G is a digraph, define a relation ~ on the vertices by: a ~ b is there is both a path from a to b, and a path from b to a. This is an equivalence relation. The equivalence classes are called the strong components of G. G is strongly connected if it has just one strong component. 6. Give the time complexity and space complexity of traveling salesperson problem. (AU2007)   Time complexity is O (n2 2n). Space complexity is O (n 2n). 7. Define NP Hard and NP Completeness. (AU- 2010) • • • DAA 13 NP-complete problems are defined as the hardest problems in NP Most practical problems turn out to be either P or NPcomplete. Study NP-complete problems … Theorem: If A is NP-Complete and A p B  B is NP-Hard In addition, if B  NP  B is NP-Complete Proof: Assume that B  P Since A p B  A  P contradiction!  B is NP-Hard AMBIKA J KINGS COLLEGE ,THANJAVUR
14. 14. Subject Code / Name: CS 2251 Design & Analysis of Algorithm 8. State if backtracking always produces optimal solution (AU- 2008) NO, backtracking always does not produce optimal solution. 9. What is a Biconnected Graph? (AU - 2010) A graph with no articulation point called biconnected. In other words, a graph is biconnected if and only if any vertex is deleted, the graph remains connected. Biconnected components: {A, C, G, D, E, F} {G, J, L, B}、B、H、I、K 10. What is a FIFO branch-and-bound algorithm? (AU - 2010) 1 Branch and Bound is a state space search method in which all the children of a node are generated before expanding any of its children. 2  Live-node: A node that has not been expanded.  In the case of backtracking the cost criteria assumes a last-in-first-out (LIFO) function, which can be realized with a stack memory. 6 3 4 7 8 9 5  A first-in-first-out cost criteria implies the FIFO branch-and-bound algorithm, and it can be realized with queue memory. A generalization to arbitrary cost criteria is the basis for the priority branch-and-bound algorithm, and a priority queue memory can be employed to realize the function. UNIT V PART-B 1. Discuss in detail about the biconnected components of a graph.(16)(AU - 2012) 2. Compare and contrast FIFO and LC branch – and – bound search techniques.(16) 3. Write a complete LC branch-and-bound algorithm for the job sequencing with deadlines problem. Use the fixed tuple size formulation. (16) (AU-2011) 4. Write a non-deterministic algorithm to find whether a given graph contains a Hamiltonian cycle. (16) 5. Write the Kruskal’s algorithm apply it to find a minimum spanning tree for the following graph : (16)(AU - 2011) 6. Write short notes on NP-hard and NP-completeness. (8)(AU - 2011) 7. Explain with an algorithm as to how 0/1 knapsack problem is solved using branch and bound technique. Apply branch and bound technique to solve the following 0/1 knapsack instance if W = 10. (8 + 8) (AU - 2010) DAA 14 AMBIKA J KINGS COLLEGE ,THANJAVUR
15. 15. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Items Weight Value 1 4 40 2 7 42 3 5 25 4 3 12 8. Write an algorithm and explain to determine Biconnected Components. 9. Prove the theorem that two Biconnected components can have at most one vertex as common and this vertex is an articulation point. (10 + 6) (AU - 2010) 10. Explain in detail the Graph Traversals. (8)(AU - 2010) 11. With an example, explain how the branch-and-bound technique is used to solve 0/1 knapsack problem. (8)(AU - 2010) UNIVERSITY QUESTION PAPERS B.E./B.Tech. DEGREE EXAMINATION, APRIL/MAY 2010 Fourth Semester Computer Science and Engineering CS2251 — DESIGN AND ANALYSIS OF ALGORITHMS (Regulation 2008) Time: Three hours Maximum: 100 Marks Answer ALL Questions PART A — (10 × 2 = 20 Marks) 1. Differentiate Time Complexity from Space complexity. 2. What is a Recurrence Equation? 3. What is called Substitution Method? 4. What is an Optimal Solution? 5. Define Multistage Graphs. 6. Define Optimal Binary Search Tree. 7. Differentiate Explicit and Implicit Constraints. 8. What is the difference between a Live Node and a Dead Node? 9. What is a Biconnected Graph? 10. What is a FIFO branch-and-bound algorithm? PART B — (5 × 16 = 80 Marks) 11. (a) Explain how Time Complexity is calculated. Give an example. DAA 15 Or AMBIKA J KINGS COLLEGE ,THANJAVUR
16. 16. Subject Code / Name: CS 2251 Design & Analysis of Algorithm (b) Elaborate on Asymptotic Notations with examples. 12. (a) With a suitable algorithm, explain the problem of finding the maximum and minimum items in a set of n elements. Or (b) Explain Merge Sort Problem using divide and conquer technique. Give an example. 13. (a) Write down and explain the algorithm to solve all pairs shortest paths problem. Or (b) Explain how dynamic programming is applied to solve travelling salesperson problem. 14. (a) Describe the backtracking solution to solve 8-Queens problem. Or (b) With an example, explain Graph Coloring Algorithm. 15. (a) Explain in detail the Graph Traversals. Or (b) With an example, explain how the branch-and-bound technique is used to solve 0/1 knapsack problem. B.E./B.Tech. DEGREE EXAMINATION, APRIL/MAY 2011 Fourth Semester Computer Science and Engineering CS 2251 — DESIGN AND ANALYSIS OF ALGORITHMS (Regulation 2008) Time : Three hours Maximum : 100 marks Answer ALL questions PART A — (10 × 2 = 20 marks) 1. Using the step count method analyze the time complexity when 2 m × n matrices are added. 2. An array has exactly n nodes. They are filled from the set {0, 1, 2,...,n-1, n}. There are no duplicates in the list. Design an O(n) worst case time algorithm to find which one of the elements from the above set is missing in the array. 3. Show the intermediate steps when the numbers 123, 23, 1, 43, 54, 36, 75, 34 are sorted using merge sort. 4. Devise an algorithm to make a change for 1655 using the Greedy strategy. The coins available are {1000, 500, 100, 50, 20, 10, 5}. 5. Write the difference between Greedy Method and Dynamic Programming. 6. Write an algorithm to find the shortest path between all pairs of nodes. 7. Define the chromatic number of a graph. 8. Draw a graph with a cycle but with no Hamiltonian cycle. 9. Define a strongly connected digraph and give the minimum in degree of all the nodes in the DAA 16 AMBIKA J KINGS COLLEGE ,THANJAVUR
17. 17. Subject Code / Name: CS 2251 Design & Analysis of Algorithm graph. 10. Perform depth first and breadth first search on the following graph and find all the nodes reachable from ‘a’. PART B — (5 × 16 = 80 marks) 11. (a) Write the recursive and non-recursive versions of the factorial function. Examine how much time each function requires as ‘n’ becomes large. Or (b) (i) Explain asymptotic notations in detail. (8) (ii) Write an algorithm for linear search and analyze the algorithm for its time complexity. (8) 12. (a) Write an algorithm to perform binary search on a sorted list of elements. Analyze the algorithm for the best case, average case and worst case. Or (b) Using the divide and conquer approach to find the maximum and minimum in a set of ‘n’ elements. Also find the recurrence relation for the number of elements compared and solve the same. 13. (a) Use function OBST to compute w(i, j), r(i, j), and c(i, j), 0<=i<j<=4, for the identifier set ( ) 4 3 2 1 , , , a a a a = (cout, float, if, while) with p(1) = 1/20, p(2) = 1/5, p(3) = 1/10, p(4) = 1/20, q(0) = 1/5, q(1) = 1/10, q(2) = 1/5, q(3) = 1/20, and q(4) 1/20. Using the r(i, j)’s, construct the optimal binary search tree. Or (b) Using dynamic approach programming, solve the following graph using the backward approach. 14. (a) Using backtracking, find the optimal solution to a knapsack problem for the knapsack instance n = 8, m = 110, (p1, p2. ... p7) = (11, 21, 31, 33, 43,53, 55, 65) and (w1, w2,...,w7) = (1, 11, 21, 33, 43, 53, 55, 65). Or (b) Write an algorithm for N QUEENS Problem and Trace it for n=6. 15. (a) Write the Kruskal’s algorithm apply it to find a minimum spanning tree for the following graph : Or (b) Write short notes on NP-hard and NP-completeness. B.E/B.Tech. DEGREE EXAMINATION, MAY/JUNE 2012 Fourth Semester Computer Science and Engineering CS 2251/141401/CS 41/CS 1251/10144 CS 402/0802300013 – DESIGN AND ANALYSIS OF ALGORITHMS (Regulation 2008) Time : Three Hours DAA 17 Maximum: 100 marks AMBIKA J KINGS COLLEGE ,THANJAVUR
18. 18. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Answer ALL questions. PART A – ( 10 x 2 = 20 marks ) 1. Define Big ‘Oh’ notation. 2. What is meant by linear search? 3. What is the drawback of greedy algorithm? 4. What is the time complexity of binary search? 5. State principle of optimality. 6. Differentiate greedy method and dynamic programming. 7. What is the difference between explicit and implicit constraints? 8. Define the basic principles of back tracking. 9. What is an articulation point in a graph? 10. What is the difference between BFS and DFS methods? PART B – ( 5 x 16 = 80 marks ) 1. (a) Discuss in detail all the asymptotic notations with examples. OR (b) with a suitable example, explain the method of solving recurrence equations. 2. (a) Explain divide – and – conquer method with merge sort algorithm. Give an example. OR (b) Explain how greedy method can be applied to solve the Knapsack problem. 3. (a) With a suitable example, explain all – pair shortest paths problem. OR (b) How is dynamic programming applied to solve the traveling salesperson problem? Explain in detail with an example. 4. (a) Explain the algorithm for finding all m-colorings of a graph. OR (b) Write down and explain the procedure for tackling the 8 – queens problem using a backtracking approach. 5. (a) Discuss in detail about the biconnected components of a graph. OR (b) Compare and contrast FIFO and LC branch – and – bound search techniques. B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2011. Fourth Semester Computer Science and Engineering CS 2251 — DESIGN AND ANALYSIS OF ALGORITHMS (Regulation 2008) Time : Three hours Maximum : 100 marks DAA 18 AMBIKA J KINGS COLLEGE ,THANJAVUR
19. 19. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Answer ALL questions. PART A — (10 × 2 = 20 marks) 1. What do you mean by linear search? 2. What is the properties of big-Oh notation. 3. What greedy algorithms? 4. What Knapsack problem? 5. What is traveling salesperson problem? 6. What do you mean by multistage graphs? 7. State the general backtracking method? 8. What is graph cloning? 9. What is spanning tree? Give an example. 10. What is NP Completeness? PART B — (5 × 16 = 80 marks) 11. (a) (i) Define Asymptotic notations. Distinguish between Asymptotic notation and conditional asymptotic notation. (10) (ii) Explain how the removing condition is done from the conditional Asymptotic notation with an example. (6) Or (b) (i) Explain how analysis of linear search is done with a suitable illustration. (10) (ii) Define recurrence equation and explain how solving recurrence equations are done. (6) 12. (a) What is divide and conquer strategy and explain the binary search with suitable example problem. Or (b) Distinguish between Quick sort and Merge sort, and arrange the following numbers in increasing order using merge sort. (18, 29, 68, 32, 43,37, 87, 24, 47, 50) 13. (a) (i) Explain the multistage graph problem with an example. (8) (ii) Find an optimal solution to the knapsack instance n = 7, m= 15 (p1, p2, p3, ….p7) = (10, 5,15, 7, 6, 18, 3) and (w1, w2, w3, ... w7) (2, 3, 5, 7, 1, 4, 1) (8) Or (b) Describe binary search tree with three traversal patterns? Give suitable example with neat diagram for all three traversal of binary search tree.(16) 14. (a) (i) How does backtracking work on the 8 Queens problem with suitable example? (8) (ii) Explain elaborately recursive backtracking algorithm? (8) Or (b) What is Hamiltonian problem? Explain with an example using backtracking. (16) 15. (a) Write a complete LC branch-and-bound algorithm for the job sequencing with deadlines problem. Use the fixed tuple size formulation. (16) DAA 19 Or AMBIKA J KINGS COLLEGE ,THANJAVUR
20. 20. Subject Code / Name: CS 2251 Design & Analysis of Algorithm (b) Write a non-deterministic algorithm to find whether a given graph contains a Hamiltonian cycle. (16) DAA 20 AMBIKA J KINGS COLLEGE ,THANJAVUR
21. 21. Subject Code / Name: CS 2251 Design & Analysis of Algorithm DAA 21 AMBIKA J KINGS COLLEGE ,THANJAVUR
22. 22. Subject Code / Name: CS 2251 Design & Analysis of Algorithm B.E./B.Tech. DEGREE EXAMINATION, NOVEMBER/DECEMBER 2007. Fourth Semester Computer Science and Engineering CS 2251 — DESIGN AND ANALYSIS OF ALGORITHMS (Regulation 2008) Time : Three hours Maximum : 100 marks PART A (Answer ALL questions) 10* 2=20 1. What is meant by stepwise refinement? 2. How is the efficiency of an Algorithm defined? 3. Give the Smoothness rule. 4. What is Algorithm Visualisation? 5. State the time complexity of bubble sort Algorithm. 6. List out any two Drawbacks of binary search algorithm. 7. What is Mathematical modelling? 8. What is Prestructuring ? Give eg. 9. What is Heuristics? 10. What is the metric used to measure the accuracy of approximation of algorithms? PART B 5*16=80 11. (a) (i) What are the important problem types focussed by the researchers? Explain any 2 with eg. (ii)What is Empirical Analysis of an algorithm? Discuss its strength and weakness (or) (b) (i) Discuss the Fundamentals of Analyse framework. (ii) Explain the various Asymptotic Notations used in Algorithm design. 12. (a)Discuss the general plan for analysing the efficiency of Non-recursive Algorithm. Write an algorithm to find the number of binary digits in the binary representation of a positive decimal integer and analyse its efficiency. (or) (b) What is the principle alternative to Mathematical analysis of an algorithm? Explain the steps in analysing the efficiency of this analysis with eg. 13. (a)Find the number of comparison made by the sentinel version of sequential search algorithm for (i) In worst case and (ii) In Average case. (or) (b) Give a suitable eg and explain the Depth First Search algorithm. 14. (a) (i) Define Heap.Explain the properties of Heap. (ii) With a simple eg Explain heap sort algorithm.(or) (b) Define Spanning tree. Discuss the design steps in Kruskal’s algorithm to construct minimum spanning tree with an eg. 15. (a) Explain subset sum problem and discuss the possible solution strategies using Backtracking. (or) (b) Discuss the solution for Knapsack problem using Branch and Bound Technique. DAA 22 AMBIKA J KINGS COLLEGE ,THANJAVUR
23. 23. Subject Code / Name: CS 2251 Design & Analysis of Algorithm Two marks answers 1. In the early days of computing the dominant vehicle for specifying algorithm was a flowchart, a method of expressing an algorithm by a collection of connected geometric shapes containing descriptions of the algorithm’s steps 2. There are two kinds of efficiency: time efficiency and space efficiency. Time efficiency indicates how fast an algorithm in question runs; space efficiency deals with the extra space the algorithm requires. 3. Let T(n) be an eventually nondecreasing function and f(n)be a smooth function. If T(n) ε Ѳ(f(n)) for values of n that are powers of where b>=2, then T(n)εѲ(f(n)) 4. 5. Algorithm Visualisation is Visualisation of the abstractions that describe software. Let f(n) be the number of comparisons required to sort the given n number using bubble sort. Then f(n) = sum of comparisons required in each scan For i= 1 we required n-1 comparison For i=2 we required n-2 comparison For i=n-1 we required n comparison Therefore f(n) = (n-1)+(n-2)+...............+2+1 =(n-1)n/2=( n2-n)/2 =O(n2) (order of n2) Computing time = O(n2) 6. It is the answer we should have fully expected: Since the algorithm simply reduces the size of the remaining array by about half an each iteration, the number of such iteration needed to reduce the initial size n to the final size 1 has to be about log2 n The logarithmic function grows so slowly that its values remain small even for every large values of n. 7. A mathematical model is an abstract model that uses mathematical language to describe the behaviour of a system. 8 Prestructuring is the 2nd type of tech. That exploits space for time tradeoffs that uses extra space to fascilitate a faster and/or more flexible access to that data. 9. A heuristics is a common – sense rule drawn from experience rather than from a mathematically proved assertion. 10. The accuracy of approx alg Sa to a problem minimizing some function f,can be quantified by size of the relative error of the approximation. r(Sa) = f(Sa)/ f(S*) PART B ANSWERS 11 (a) (i) Important problem types are Sorting Searching String Processing Graph problem Combinatorial Problems Geometric Problems Numerical Problems(Refer page no 19 of Anany Levitin) (ii) A general plan for empirical analysis of algorithm efficiency: 1. Understand the experiment’s purpose 2. Decide on the efficiency metric M to be measured and the measurement unit 3. Decide on characteristics of the input sample 4. Prepare a program implementing the algorithm for the experimentation DAA 23 AMBIKA J KINGS COLLEGE ,THANJAVUR
24. 24. Subject Code / Name: CS 2251 Design & Analysis of Algorithm 5. Generate a sample of inputs 6. Run the algorithm on the sample’s inputs and record the data observed 7. Analyze the data obtained(Refer page no 85 from Anany Levitin) 11. (b) (i) Analysis Framework: -Measuring an input’s size -Unit for measuring running time - Order of growth -Worst-case, Best-case and Average –case Efficiencies (ii) Big Oh: The function f(n) = O(g(n)) iff there exist positive constants C and no such that f(n)C * g(n) for all n, n , n0. Omega: The function f(n) =W (g(n)) iff there exist positive constant C and no such that f(n) C * g(n) for all n, n n0.  Theta The function f(n) =(g(n)) iff there exist positive constant C1, C2, and no such that C1 g(n), f(n) C2 g(n) for all n, n n0. Little Oh The function f(n) = 0(g(n)) Iff Lim f(n) = 0 n - g(n) Little omega The function f(n) = (g(n)) Iff Lim g(n) = 0 n - f(n) 12.(a) (i)General Plan for Analyzing efficiency of Non recursive Algorithm: -Decide on a parameter indicating an input’s size -Identify the algorithm’s basic operation - Check whether the number of times the basic operation is executed depends only on the size of an input. - Set up a sum expressing the number of times the algorithm’s basic operation is executed. - Using standard formulas and rules of sum Manipulation (ii) Refer Page no 66 from Anany Levitin (b) Refer Page no 69 from Anany Levitin 13. (a) – Definition for sequential search- It compares given element with all the elements in an array - Algorithm for sequential search - Briefly explain about efficiency class for sequential search 13.(b) Algorithm for DFS:Step-1: Set the starting point of traversal and push it inside the stack Step-2: Pop the stack and add the popped vertex to the list of visited vertices Step-3: Find the adjacent vertices for the most recently visited vertex( from the Adjacency Matrix) Step-4: Push these adjacent vertices inside the stack (in the increasing order of their depth) if they are not visited and not there in the stack already Step-5: Go to step-2 if the stack is not empty 14. (a) (i) Heap -A heap can be defined as a binary tree with keys assigned to its nodes provided the following two conditions are met 1. the binary tree is essentially complete 2. The Key at each node is greater than or equal to the keys at its children (ii) Refer Page no 219 from Anany Levitin (b) A minimum spanning tree (MST) or minimum weight spanning tree is then a spanning tree with weight less than or equal to the weight of every other spanning tree. More generally, any DAA 24 AMBIKA J KINGS COLLEGE ,THANJAVUR
25. 25. Subject Code / Name: CS 2251 Design & Analysis of Algorithm undirected graph (not necessarily connected) has a minimum spanning forest, which is a union of minimum spanning trees for its connected components - Definition for minimum spanning tree - prim’s Algorithm for MST - Explain the graph in stepwise procedure by drawing graph and tabulation 15.(a) The subset sum problem is a good introduction to the NP-complete class of problems. There are two reasons for this  It is a decision and not an optimization problem  It has a very simple formal definition and problem statement. Although the subset sum problem is a decision problem, the cases when an approximate solution is sufficient have also been studied, in the field of approximations algorithms; 15. (b) (i)The term Branch-and-Bound refers to all the state space methods in which all children of the E-node are generated before any other live node can become the Enode. 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. LC search ii. 15 – puzzle problem iii. LC control abstraction iv. Bounding v. FIFO branch and bound vi. LC branch and bound (ii) Given n objects and a knapsack or bag. Object I has a weight wi and the knapsack has the capacity m. If a fraction xi 0<xi<1 of object i is placed in to knapsack then a profit of pixi earned. The objective is to obtain a filling of the knapsack that maximizes the total profit earned. Since the knapsack capacity is m, we require the total weight of all chosen objects to be almost m. ********************************** ALL THE BEST ************************************ DAA 25 AMBIKA J KINGS COLLEGE ,THANJAVUR