This action might not be possible to undo. Are you sure you want to continue?

Chennai – 600 097 Computer Science & Engineering Two Mark Questions and answers

**Subject Code : CS 1201 Subject : Design and Analysis of algorithms - Unit-I
**

1. Define an Algorithm. An algorithm is a sequence of unambiguous instructions for solving a problem,i.e., for obtaining a requiered output for any legitimate input in a finite amount of time. 2. What is algorithmics?. Algorithmics is more than a branch of computer science. It is the core of computer science and ,in all fairness ,can be said to be relevant to most of science ,business ,and technology. 3. What is algorithm design technique? An algorithm design technique (or “strategy” or “paradigm”) is a general approach to solving problems algorithmically that is applicable to a variety of problems from different areas of computing. 4. How is an algorithm's time efficiency is measured? The time efficiency is computed by 1) Measuring the input size – If the input size is longer then algorithm runs for a longer time. 2) Measuring the running time - To measure the running time ,it is necessary to identify the basic operation of an algorithm and measure the time taken to execute the basic operation. 5. How an algorithm is specified? Algorithms can be specified using pseudocode which is a mixture of natural language and programming language like constructs. A pseudocode is more precise than a natural language,and often yields more succint algorithm descriptions. 6. What is correctness of algorithm? The algorithm's correctness is ascertained ,if the algorithm yields the requiered results for every legitimate input in a finite amount of time. 7. What are the two kinds of algorithm efficiency? The two kinds of algorithm efficiency are : Time efficiency – which indicates how fast the algorithm runs. Space efficiency – which indicates how much extra memory the algorithm needs. 8. What are important problem types?

11. 15. 12. 13. What are fundamental data structures? Linear data structures – Linked lists.E) is defines by a pair of two sets: A finite set V of items called vertices and set E of pairs of these items called edges. what is the formula used to calculate the algorithm's running time? The running time T(n) of a program implementing the algorithm on a computer is given by the formula : T(n) = Cop x C(n) where Cop is the time of execution of an algorithm's basic operations C(n) is the the number of times the basic operation is executed. What is a graph? A graph G = (V. What is a Abstract Data type? It is a set of abstract objects with a collection of operations that can be performed on them.Usually the basic operation is the most time consuming operation in the algorithm's inner most loop.The important problem types are Sorting Searching String processing Graph problems Combinatorial problems Geometric problems Numerical problems 9.queues Graphs Trees Sets and dictionaries 10. What is the order of growth? . How a graph is represented? Graphs for computer algorithms are represented in two principal ways: the adjacency matrix and adjacency linked lists.stacks. What is an algorithm's basic operation? It is an operation that contributes the most to the total running time of the algorithm.

The Order of growth is the scheme for analyzing an algorithm's efficiency for different input sizes which ignores the multiplicative constant used in calculating the algorithm's running time. What are asymptotic notations? Asymptotic notation is the short hand way to represent the time complexity.which is an input of size n for which the algorithm runs the longest among all possible inputs of that size. List 5 of basic efficiency classes. 16. 17.if t(n) is bounded above by some constant multiple of g(n) for all large n. Measuring the performance of an algorithm in relation with the input size n is called the order of growth.i. = lim t'(n) n->oo -------g'(n) . What is the worst-case efficiency of an algorithm? The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size n. Write Euclid's algorithm and explain the steps. What is L'Hopital's rule? lim n->oo t(n) -------g(n) Unit-1 Long questions Explain in detail the algorithm design and analysis process. What is Big O Notation? Big O notation is the method of representing the upper bound of algorithm's running time.e. Explain in detail the fundamental data structures.denoted by t(n) E O(g(n)).if there exists some positive constant c and some non negative integer n0 such that t(n) <= cg(n) for all n >= n0.. A function t(n) is said to be in O(g(n)). log n n nlogn n2 2n logarithmic linear n-log-n quadratic exponential 18. Explain in detail the important problem types.

as a function of n.0. What are asymptotic notations? Define and explain the three notations used by computer scientists for analyzing the efficiency of algorithms.one of the method used is called the method of backward substitution. Such equations are called recurrence relations or recurrences.best-case and the average case effuieciencies.but implicitly as a function of its value at another point.i+1 to n-1 do if A[i] = A[j] return false return true Write an algorithm for matrix multiplication problem.. ALGORITHM MatrixMultiplication(A[0. What is the method of backward substitution? Among several techniques available for solving recurrence relations.. ALGORITHM UniqueElements(A[0.n-1].0 to n-1 do .n-1. The method's idea will be clear by referring to the particular case as shown below : M(n) = M(n-1) + 1 for n > 0.0. Explain in detail the general framework for analyzing an algorithm's efficiency. M(0) = 0 = [M(n-2) + 1] + 1 = M(n-2) + 2 = [M(n-3) +1] + 2 = M(n-3) + 3 =M(n-n) + n = n.namely n-1. Write an algorithm for element uniqueness problem.n-1]) for I <-..B[0. What is Order of growth? Plot the order of growth for different functions.Write sieve of Eratosthenes algorithm which generates consecutive primes and explain.e.Unit-2 What are recurrence relations? Consider the function M(n) = M(n-1) + 1 Here the equation defines M(n) not explicity .0 to n-2 do for j <-. Explain with examples the worst-case.0 to n-1 do for j <-..n-1. Design and Analysis of Algorithms ..i.n-1]) for i <-. What are basic efficiency classes? Explain in detail.

j) + A[i.. 1 ....0 for k <-..1 while n > 1 do count <-.count + 1 n <-.j) <-..k] * B[k. ALGORITHM Binary(n) count <-.0 to n-1 C(i.C(i.j] retutn C Write an algorithm for finding the number of binary digits in the binary representation of a positive decimal integer.0.L n/2 _| return count Show the tree structure for recursive calls made in the problem of towers of Hanoi.C(i.j) <-. 2 1 1 . n n-1 n-2 2 1 1 n-2 n-2 2 1 1 n-1 n-2 2 1 . .

Write an algorithm for finding the nth fibonacci number. Fibonacci numbers are obtainted by recursive calls. Draw a tree of recursive calls for fib(6). ALGORITHM F(n) if n <= 1 return 1 else return F(n-1) + F(n-2) What is algorithm visualization? Algorithm visualization can be defines as the use of images to convey some useful information about algorithms. Fib 5 Fib 3 Fib 1 1 Fib 1 1 Fib 2 Fib 0 0 Fib 0 0 Fib 4 Fib 2 Fib 1 1 1 Fib 3 Fib 1 Fib 0 0 Write a recursive algorithm for finding the factorial of a non negative integer. ALGORITHM F(n) Fib 2 1 . Two principal variations are Static algorithm visualization Dynamic Algorithm visualization(also called algorithm animation) What are the some of the desirable features of animation's user interface? Be consistent Be interactive Be clear and concise Be forgiving to the user Adapt to the knowledge level of the user.

if n= 0 return 1 else return F(n -1) * n What is a scatter plot? Graphical representation of empirical data obtained as the result of an experiment is called a scatter plot. But this is more difficult to implement. mathematical derivation is involved The principal weakness is limited applicability The principal strength is it is independent of any input The principal strength is it is applicable for any algorithm The principal weakness is it depends upon the sample input What is the principal strength of mathematical analysis of algorithms? The principal strength of mathematical analysis is its independence of specific inputs. Then a sum is set up and is simplified using standard rules and formula. The execution of the basic operation depends upon the input size n. What is the principal alternative to the mathematical analysis of algorithm's efficiency? Empirical analysis It is done by running the algorithm on the sanple inputs and recorsing the data observed. What is the tool for analyzing the time efficiency of a non recursive algorithm? For analyzing the time efficiency of non recursive algorithm we need to find the input size as well as the basic operation of the algorithm. What is the possible application of empirical analysis? One of the possibilities of the empirical analysis is to attempt predicting the algorithm's performance on the sample size not included in the experiment's sample. What is algorithm animation? Algorithm animation shows a continuous movie like presentation of an algorithm's operations. . The algorithm is analyzed with the help The algoprithm is analysed by taking of mathematical derivations and there is some sample of input and no no need of specific input. Then the data is analysed and a scatter plot is prepared. ri <-( a * ri-1 + b) mod m Differentiate : Mathematical and Empirical analysis. What is linear congruent method? It is a well known algorithm for generating pseudo random numbers.

what is the empirical analysis of algorithm? Discuss its strength and weakness. Unit-2 Long questions Explain the general plan for analyzing efficiency of non recursive algorithms. Design a non recursive algorithm for computing the product of two nxn matrices and also find the time efficiency of the algorithm.usually directly based on the problem's statement and definitions of the concepts involved. Discuss the features of animation of an algorithm.What is the principal strength of empirical analysis of algorithms? The principal strength lies in the applicability to any algorithm. Write an algorithm for matrix multiplication and explain Explain the general plan for analyzing efficiency of recursive algorithms. Design and analysis of algorithms .Unit-3 What is Brute force approach? Brute force is a straight forward approach to solving a problem. Write an algorithm for element uniqueness problem and explain. Write short note on algorithm visualization and its applications. Design a recurssive algorithm to compute factorial function f(n) = n! for an arbitrary non negative integer n and derive the recurrence relation. Explain the Tower of Hanoi puzzle and how the recurrence relation is solved for the moves. Give some examples of Brute force approach? a) Selection sort b) bubble sort c) string matching What is the principal strength of brute force approach? Wide applicability and simplicity What are the general plan of divide and conquer strategy? .

Quicksort is based on the divide-and-conquer approach. r <-. ALGORITHM BinarySearch(A[0.ideally about the same size.n-1] to achieve its position.Otherwise.n-1].0.the algorithm stops. It rearranges elements of a given array A[0.worst and average case time complexity of merge sort is O(nlogn) The drawbacks : (I) This algorithm requiers extra storage to execute this method (ii) This mehod is slower than the quick sort method (iii) This method is complicated to code. Time efficiency : The best.we partition the given array into two subarrays based on the value stored in the element called pivot. Explain briefly how binary search works. How merge sort works? Merge sort is the sorting algorithm which uses the divide and conquer strategy. Give the time efficiency and drawback of mergesort algorithm.It works by comparing a search key 'K' with the array's middle element A[m]. Explain the quick sort algorithm. By this method the array is divided into two halves.a situation where all elements before some positions 's' are smaller than or equal to A[s] and all the elements after position 's' are greater than equal to A[s] What is a pivot? In quicksort .|_ (I + r)/2_| if K = A[m] return m . Then the sorted halves are merged to get the sorted array. Unlike mergesort. These halves are sorted recursively.n-1 while l <= r do m <-. Binary search is remarkably efficient algorithm for searching in a sorted array.The problem's instance is divided into several smaller instances of the same problem.If they match. The smaller instances are solved typically recursively The solutions obtained for the smaller instances are combined to get a solution to the original problem...quicksort divides them according to their value.the same operation is repeated recursively for the first half of the array if K < A[m] and for the second half if K > A[m]. Write the Binary search algorithm.K) l <-.which divides its input's elements according to their position in the array.

Write a recursive algorithm for computing the height of a binary tree. ALGORITHM Height(T) //Input : A binary tree T //Output : The height of T if T = 0 return -1 else return max{Height( TL).m-1 else m <-.m + 1 return -1 What is the time complexity of binary search in worst case? Let the number of comparisons made in binary search algorithm = Cw(n) We have Cw(n) = Cw(|_n/2_|) + 1 for n > 1. Cw(1) = 1 = Cw(2k/2) + 1 = Cw(2k-1) + 1 = Cw(2k-2) + 2 Let n = 2k Then Cw(2k) = k + 1 log (n+1) What is a binary tree? A binary tree T is defines as a finite set of nodes that is either empty or consists of a root and two disjoint binary trees TL and TR called resp. What are the three major variations of the decrease-and-conquer technique? The three major variations of the decrease-and-conquer technique are Decrease by a constant decrease by a constant factor variable size decrease .the left and right sub tree of the root.Height( TR)} + 1 What is decrease-and-conquer technique? The decrease-and-conquer technique is based on exploiting the relationship between a solution to a given instance of a problem and solution to a smaller instance of the same problem.else if K < A[m] r <-.

Give an example of decrease by a constant Consider the exponentiation problem of computing an The relationship between a solution to an instance of size n and an instance of size n and instance of size n-1 is obtained by the obvious formula : an = an-1 . Cw(n) = (n-1)n/2 = O(n2) Compare depth first search and depth first search. .n) = gcd(n.m mod n) In the above formula the arguments in the right hand side are always smaller than the left hand side. 2)Design a recursive decreae-by-one algorithm for sorting the n real numbers in an array with an example and determine the number of key comparisons and time efficiency of the algorithm. The right hand side decreases by a variable factor. Explain with an example. SNO 1 2 Depth first traversal uses stack data structure The DFS sequence is composed of tree edges and back edges the efficiency of adjacency matrix graph is O(V2) Breadth first traversal uses queue data structure The BFS sequence is composed of tree edges and cross edges the efficiency of adjacency matrix graph is O(V2) 3 What are the applications of depth first search? To check connectivity and acyclicity of graph To find articulation point Unit-3 Long questions 1)Write a pseudocode for divide and conquer algorithm for merging two sorted arrays into a single sorted one. a if n > 1 | a if n = 1 Give an example of variable size decrease gcd(m. a So the function f(n) = an can be computed by using the recursive definition f(n) = | f(n-1) . Derive the worst case complexity of insertion sort.

Unit-4 Unit-4 Long questions 1)Define AVL tree. Analyze your algorithm's 7)Using the bruteforce string matching algorithm match the pattern “EXAMPLE” from the text “This_IS_A_SIMPLE_EXAMPLE”. 4)Solve the all pairs shortest path problem for the digraph with the weight matrix given below : 5)Give a suitable example and explain the breadth first search and depth first search algorithms. Design and analysis of algorithms . 8)What is the principal idea behind decrease and conquer? Compare and contrast decrease and and conquer with divide and conquer approach. 9)Compare DFS and BFS. 3)Construct a minimum spanning tree using Kruskal's algorithm with an example. Explain the construction sequence of AVL tree with a simple example. Analyze your algorithm's 7)Using the bruteforce string matching algorithm match the pattern “EXAMPLE” from the text “This_IS_A_SIMPLE_EXAMPLE”. 9)Compare DFS and BFS.Unit-5 Unit-5 Long questions . 8)What is the principal idea behind decrease and conquer? Compare and contrast decrease and and conquer with divide and conquer approach. 4)Write an algorithm for Binary search tree and analyse its efficiency. 6)Give an algorithm for selection sort. Explain in detail the general divide and conquer recurrence.3)Explain quick sort algorithm with an example. 6)Give an algorithm for selection sort. Design and analysis of algorithms . 2)Define spanning tree. 5)Give a suitable example and explain the breadth first search and depth first search algorithms. Discuss the design steps in Prim's algorithm to construct a minimum spanning tree with an example. 10) Explain in detail the general divide and conquer recurrence.

10)Write short notes on a)back tracking b) Branch and bound c) State space tree d)promising and non promising nodes . S = {1.1)Explain subset-sum problem and discuss the possible solution strategies using back tracking. ITEM 1 2 3 4 WEIGHT 4 7 5 3 VALUE $ 40 $42 $25 $12 The knapsack capacity W = 10 4)Differentiate between back tracking and branch-and-bound methods. 7)Explain with an example the assignment problem.3. 6)Explain with an example the Hamiltonian circuit problem. 9)Apply backtracking technique to solve the following instance of the subset sum problem.4. 3)Solve the following instance of knapsack problem by branch-and-bound algorithm. 8)Write an algorithm Backtrack and explain. 5)Construct a state-space-tree and solve the 4 queen problem. 2)Discuss the solution for traveling salesman problem using brach and bound technique.5} and d = 11.

Sign up to vote on this title

UsefulNot useful- DAA 2MARKS
- DAA
- Analysis And Design Of Algorithms (ADA) 2 marks question
- DAA ADA Viva Questions
- adaNotes-1
- data structure and c++ lab manual
- Ada Lab Manual-rvce
- Algorithm Analysis and Design
- A Notes on Design & Analysis of Algorithm
- Suggestion Paper for CS503 - Design and Analysis of Algorithm
- Preface of Algorithms
- Lecture 04
- Lecture Notes1
- Algorithms for Marketing-Mix Optimization
- T14.SortingAnalysis
- Grup-9 NP Hard & Cmplete
- Lec3 Divide Conquer c
- Divide And Conquer method
- N Queen Problem
- Analisis design algoritma
- Materi Analisis dan Design Algoritma
- sample.pdf
- Lec02 Algorithm Analysis
- Big-O Algorithm Complexity Cheat Sheet
- MCA4040 smu mca fall 2013 assignment
- 1999 Operations Research
- Example-workbook-ASAP-Utilities-formulas.xls
- CIRRELT-2007-41 - BOX PACKING.pdf
- 50494_18.pdf
- T CO3 FaceRecognition
- DAA-2-marks

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.