## Are you sure?

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

& TECHNOLOGY, TANGORI (MOHALI)

Department of Computer Science and Engineering

COURSE FILE

DESIGN & ANALYSIS OF ALGORITHMS

CS - 307 5TH SEM C.S.E

Teacher: Er. Gurjot Singh Sodhi

July - November 2012

Course File - Design & Analysis of Algorithms

RATIONALE :

Informally, an algorithm is any well-deﬁned computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into the output. We can also view an algorithm as a tool for solving a well-speciﬁed computa-tional problem. The statement of the problem speciﬁes in general terms the desired input/output relationship. The algorithm describes a speciﬁc computational proce- dure for achieving that input/output relationship. For example, one might need to sort a sequence of numbers into non decreasing order. This problem arises frequently in practice and provides fertile ground for introducing many standard design techniques and analysis tools. Here is how we formally deﬁne the sorting problem:

Input: A sequence of n numbers 〈a1 , a2 , . . . , an 〉. Output: A permutation (reordering) 〈a1 , a2 , . . . , an 〉 of the input sequence such that a1 ≤ a2 ≤ · · · ≤ an .

For example, given the input sequence 〈31, 41, 59, 26, 41, 58〉, a sorting algorithm returns as output the sequence 〈26, 31, 41, 41, 58, 59〉. Such an input sequence is called an instance of the sorting problem. In general, an instance of a problem consists of the input (satisfying whatever constraints are imposed in the problem statement) needed to compute a solution to the problem. Sorting is a fundamental operation in computer science (many programs use it as an intermediate step), and as a result a large number of good sorting algorithms

Which algorithm is best for a given application depends on—among other factors—the number of items to be sorted, the extent to which the items are already somewhat sorted, possible restrictions on the item values, and the kind of storage device to be used: main memory, disks, or tapes. An algorithm is said to be correct if, for every input instance, it halts with the correct output. We say that a correct algorithm solves the given computational problem. An incorrect algorithm might not halt at all on some input instances, or it might halt with an answer other than the desired one. Contrary to what one might expect, incorrect algorithms can sometimes be useful, if their error rate can be controlled.

An algorithm can be speciﬁed in English, as a computer program, or even as a hardware design. The only requirement is that the speciﬁcation must provide a precise description of the computational procedure to be followed.

2|Page

Course File - Design & Analysis of Algorithms

What kinds of problems are solved by algorithms? Sorting is by no means the only computational problem for which algorithms have been developed. (You probably suspected as much when you saw the size of this book.) Practical applications of algorithms are ubiquitous and include the follow-ing examples:

•The Human Genome Project has the goals of identifying all the 100,000 genes in human DNA, determining the sequences of the 3 billion chemical base pairs that make up human DNA, storing this information in databases, and devel-oping tools for data analysis. Each of these steps requires sophisticated algo-rithms. The savings are in time, both human and machine, and in money, as more information can be extracted from laboratory techniques.

•The Internet enables people all around the world to quickly access and retrieve large amounts of information. In order to do so, clever algorithms are employed to manage and manipulate this large volume of data. Examples of problems which must be solved include ﬁnding good routes on which the data will travel (techniques for solving such problems ), and using a search engine to quickly ﬁnd pages on which particular information resides

1.1 Algorithms

•Electronic commerce enables goods and services to be negotiated and ex-changed electronically. The ability to keep information such as credit card num-bers, passwords, and bank statements private is essential if electronic commerce is to be used widely. Public-key cryptography and digital signatures are among the core technologies used and are based on numerical algorithms and number theory.

•In manufacturing and other commercial settings, it is often important to allo-cate scarce resources in the most beneﬁcial way. An oil company may wish to know where to place its wells in order to maximize its expected proﬁt. A candidate for the presidency of the United States may want to determine where to spend money buying campaign advertising in order to maximize the chances of winning an election. An airline may wish to assign crews to ﬂights in the least expensive way possible, making sure that each ﬂight is covered and that government regulations regarding crew scheduling are met. An Internet service provider may wish to determine where to place additional resources in order to serve its customers more effectively.

3|Page

Course File .Design & Analysis of Algorithms SYLLABUS 4|Page .

The Art of Computer Programming. 1976.Course File .and C.Knuth. NP-hard and NP-complete. OBJECTIVES: Date Structures are an integral part of algorithm design and Discrete Structures covers topics like graph theory. Jr.Design & Analysis of Algorithms CS . 3. 1968. Branch and bound. [L-8] Algorithm design techniques: divide and conquer. Purdom. search and traversals. [L12] Problem classes P. Aho. Algorithm analysis.Mehlhorn. 1984. 1984. Approximation algorithms for some NP-complete problems. NP.D. Holt Rinechart and Winston. Brown. order arithmetic.V. J. string processing algorithms. time and space complexities and average and worst case analysis. Dynamic programming. Vols. Backtracking. Vols. Ullman. Fundamentals of Computer Algorithms. design and Analysis of Algorithms. K. Hard problems and approximation algorithms. 1985.E. 2. Data Structures and Algorithms. A. Algebraic algorithms. set algorithms. 2. deterministic and non deterministic polynomial time algorithms.307 DESIGN AND ANALYSIS OF ALGORITHMS External Marks: 60 L T P Internal Marks: 40 3 1 Total Marks: 100 PREREQUISITES: Discrete Structures and Data Structures. D. 1 and 2. Galgotia Publishers.Horowitz. COURSE CONTENTS: Models of computation. Sahni. Addison Wesley. [L-6] TEXT BOOKS 1. 1 and 3.Hopcroft. lower bounds. S. The Analyses of Algorithms. 5|Page .E. [L-16] Sorting and searching algorithms. Springer Verlag. REFERENCES: 1. J..1975. combinatorial algorithms. Addison Wesley.

Course File .NO TOPICS PAGE NO.Design & Analysis of Algorithms INDEX S. 1 2 3 4 5 6 7 Time Table Assignments Sessionals Question Bank University Papers Viva Voice Questions Tutorial Sheet 7 9 11 16 23 28 34 6|Page .

Course File .Design & Analysis of Algorithms TIME TABLE Period/Days Monday Tuesday Wednesday Thursday Friday LAB T 1 L L 2 3 4 LAB LAB LAB L L T 5 6 7 8 9 Period/Days Monday Tuesday Wednesday Thursday Friday 1 2 T 3 4 5 6 7 LAB 8 9 L L L L T LAB LAB LAB 7|Page .

Course File .Design & Analysis of Algorithms ASSIGNMENTS 8|Page .

Course File . NP Classes. ASSIGNMENT – 3 Q1) Explain P. 9|Page . Q2) Discuss Approximation Algorithms. ASSIGNMENT – 2 Q1) Solve 2nd Sessional Paper . Q2 ) Explain all the Sorting techniques.Design & Analysis of Algorithms ASSIGNMENT – 1 Q1 ) Explain all the Searching techniques.

Course File .Design & Analysis of Algorithms SESSIONALS 10 | P a g e .

j]+ b[i. The order of complexity of Binary Search in Best case is --------in the average case is -------in the worst case is ----------Q 2 ) How the time and space complexities measured for an algorithm? Q 3 ) What is the computing time for the following statement { for i=1to m do for i=1 to n do c[i. } Q 4 ) What do you mean by the term Lower bound & Upper bound.Tangori SESSIONAL TEST : 1 Subject : DAA Semester : 5th (A+B) Max Marks : 30 Max Time :11/2hrs SECTION A Q 1 ) a. Q 5 ) What do you mean by Growth of Functions. Q 3 ) Solve the following expression – 5*6+(5+(3/5+4)-1)*3/(5+2) SECTION C 1*10 = 10 marks Q 1 ) Write an algorithm for the following & calculate their Time Complexitya. Is 2n+1=O(2n) ? Give reasons.Course File . SECTION B 2 * 5 = 10 marks Q 1 ) Explain the use of asymptotic notations in the analysis of algorithms. Q 2 ) Explain an algorithm to insert 5 elements in a Stack and in a Queue.Design & Analysis of Algorithms Shaheed Udham Singh College of Engg & Technology.j]:= a[i. Quick Sort b.j]. Binary Search Q 2 ) Explain various Models of Computation. 11 | P a g e . 5 * 2 = 10 marks b.

c. Explain the Subset-Sum problem using the followingS=<3. Explain Floyd-Warshall Algorithm with an example.f> . performa) BFS or DFS b) All spanning tree 1*10=10 12 | P a g e .5.6> .Tangori SESSIONAL TEST : 2 Subject : DAA Semester : 5th ( A & B ) Max Marks : 30 Max Time : 11/2 hrs SECTION-A Q1. Given S<a. What do you mean by Order Arithmetic? Q3. Q2. X=9 SECTION-C Q1.d.e. Write a note on String Matching Algorithm? Q2.Course File . Starting from vertex V4. Build binary tree according to Greedy Strategy.b. (b) Differentiate between Iteration and Recursion.(a) Define lower bound & Upper bound. Define a) Cyclic interchange b) Minimum Spanning Tree Q2. Explain Knacksap Problem using Branch and Bound.1. Q4.2. SECTION-B 5*2=10 2*5=10 Q1.4. Differentiate between BFS& DFS? Q5.Design & Analysis of Algorithms Shaheed Udham Singh College of Engg & Technology.5. Probability(P)=<1.3.8>. Q3. Differentiate between Krushkal Algorithm & Prim’s Algorithm? Q4.

Design & Analysis of Algorithms Q3 From the given graph. draw a) Minimum Spanning Tree by Krushkal Algorithm b) Minimum Spanning Tree by Prim’s A8lgorithm c) Shortest Path from V1 to V 13 | P a g e .Course File .

Insertion sort and Bubble sort which sorting technique is the best in worst case. Support your arguments with an example and analysis. Q 3 ) Among Merge sort. Q 2 ) Write a algorithm for (a) Quick sort. SECTION B 2 * 5 = 10 marks Q 1 ) Differentiate between N-P Hard and N-P Complete problems with example. 14 | P a g e .Tangori SESSIONAL TEST : 3 Subject : DAA Semester : 5th ( A & B ) Max Marks : 30 Max Time : 11/2 hrs SECTION A Q 1 ) (a) What is stable sorting? (b) Define Cooks – Levin Theorm. (b) Polynomial time algorithm.Course File . Q 2 ) Given an example of an algorithm which is infinite in nature Q 3 ) What are Stored RAM model? 5 * 2 = 10 marks Q 4 ) What is time complexity. What is the time complexity of Merge Sort? Q 5 )Name three conditions under which sequential search of a list is preferable to binary search. lines and characters in a given text.Design & Analysis of Algorithms Shaheed Udham Singh College of Engg & Technology. Q 5 ) Write an algorithm for Knapsack problem using greedy method. (b) Merge Sort Q 3 ) Explain the relationship between Turing Machine and RAM models. SECTION C Q 1 ) Write short note on following: (a) Techniques for algebraic problems. Q 4 ) Design an algorithm which finds number of words. 1*10 = 10 marks Q 2 ) What are approximation algorithms? Differentiate between deterministic and nondeterministic algorithms .

Design & Analysis of Algorithms QUESTION BANK 15 | P a g e .Course File .

j<n. 13. Is 2n+1=O(2n)? What is the worst case running time of Quick Sort? What is the worst case running time of algorithm to delete each element from the linked list? Which is more efficient of BFS and DFS? What are maximum and minimum number of elements in a heap of height h? Where in a heap might the smallest element reside? Differentiate between NP Hard and NP Complete . by divide and conquer technique. 32. What is recursion?What are its drawbacks? The order of complexity of Binary Search in Best case is -----in the average case is ------in the worst case is -------If W= MNOP. 4. Write an algorithm for insertion sort. 5. Give the definition for 0/1 knapsack problem.62. 38. What is NP Hard Problem? What is Ordering Paradigm? Differentiate between full and complete Binary Tree. That is root is visited first then the intermediate children of root then grand children of root and so on. for(i=1. 28.Design & Analysis of Algorithms QUESTION BANK 1. 24. Define the term Divide and Conquer. 25. 19. 14. 22. 16. 36. 9. 6.i<n. 30. 12. 7. 35. 15. 26. What is the order of the computation for the following loop.i+1) for(j=1. 17. 2. Also give its computing time. 41. 10. 20.list all substrings of W. 27. 23. What are various steps used in design of an algorithms?Give an example of algorithm which is infinite in nature. Define non deterministic algorithm. What is lower bound? What are explicit and implicit constraints? What is algebraic simplification? 16 | P a g e . 20 . 37. 21. What are the various set operations possible? What is algorithm of Pre Order Traversal. 29. 40. 18. 16. 10. What is Binary Search Tree? 31.Course File . 39. What is time complexity ? What is space complexity? Give brief concept of Divide and conquer. 34. 42. What are the advantages of dynamic programming over greedy method? What are the various techniques for design of various algorithms? How the time and space complexities measured for an algorithm? What is the order of Bubble Sort? What are the conditions under which backtracking can be used? What is Optimal Merge Pattern Problem? What is algorithm for in order traversal? What is solution space in Backtracking Techniques ? How will Merge Sort sort the 6 numbers: 40. Write an algorithm that will traverse a binary tree level by level. 11. 18. Write an algorithm to sort an array containing 0's and 1's with complexity of order of n . How does heap Sort work? Explain the backtracking Problem with 4 Queens on a 4*4 chess board. 8. Differentiate between Binary and Binary Search Tree. 3.j+1) 33.

Among Quick Sort. 47.treating them as a pair of digits in a range of 0-9. How does it help in finding a solution for Branch and Bound Algorithm. What is Criterion Function ? Define the Principal of Optimality. 61.find out the shortest distance of all the nodes from the node A . 45. 46. What do you mean by Time and space complexity.Explain at least 2 operations on strings with algorithms.What are time and space requirements of your algorithm 59. 58.Bin Sort. 60. Give an algorithm to count number of leaf nodes in a Binary Tree t and what is its computing time 51.Course File . Write short notes on the following: (A)Dynamic Programming ( B) Branch and Bound 55.j) appears on the adjacency list for both vertex i and j 50. Here are 16 integers: 22 36 6 79 26 45 75 13 31 62 27 76 33 16 62 47 . Explain basic concepts of NP hard and NP Complete problems. 52. What type of operations can be performed on string's . What is criterion function in backtracking?What is solution space for backtracking problem? Explain by taking sum of subset as a problem 64. What are the various methods or techniques in which various algorithms can be expressed? 63. Differentiate between Deterministic and Non Deterministic algorithms.Insertion Sort Heap Sort.Remember that the edge (i. 48. Write an string processing algorithm to identify whether a particular sequence of character is in string or not. Which algorithm is best to sort the data and why? 56. Explain the use of asymptotic notations in the analysis of algorithms 53. Describe an algorithm to insert and delete edges in the adjacency list representation for an undirected graph . What are Decision Problems? What is Interpolation of polynomial? Short Answer Type Questions 49.What will be the order of complexity of a Binary Search in the unsuccessful case 57.Explain with the help of suitable algorithms.Write an algorithm to find out minimum number of edges to be added to G so that G becomes disconnected .Design & Analysis of Algorithms 43. 54. 62.Heap Sort. How will u represent a polynomial using dense representation strategy. In the following Graph . Let G be a connected and undirected graph .Insertion Sort . What is LC Search. 17 | P a g e .Your algorithm should output such a set of edges . What are the disadvantages of Binary Search algorithm . 44.Sort them using a Quick Sort . What is time and space complexity of “Insertion Sort”?Explain.

Using the recursive algorithm . What is Greedy Method ?Write an algorithm for knapsack problem using Greedy Method.30 respectively. Define Principal of Optimality. Also represent the merge pattern using Binary Tree.10. 68. 88. Explain the different terminologies for tree and graph 87. What will be time and space complexity for the algorithms. 81.j]+ b[i. return s . Justify the statement “An optimization problem can be solved in the polynomial time if and only if the corresponding decision problem can. 67. Give brief concept of Algebraic Simplification and algebraic transformation 79.X2. Explain what do you mean by algebraic problem . Explain how to validate and analyze the algorithm .. What is the computing time for the following statement {for i=1to m do for i=1 to n do c[i.Course File . 66. Explain by giving a suitable example 71.Discuss various techniques for algebraic problems. 80. for i=1 to n do s=s+a[i].5. 75. } 84.” 72.Design & Analysis of Algorithms 65. Explain the Big Oh notation used in the analysis of algorithm 73.explain how the tower of Hanoi problem can be solved. What is 8 Queens problem?How does backtracking helps in solving it. Merge the files (X1. Explain an algorithm to insert 5 elements in stack and in a Queue. Define Prim's and Kruskal Algorithms 89. Algorithm sum(a.Explain All pairs Shortest Path problem 18 | P a g e . Explain Traveling Salesperson Problem 90. What is Optimal Merge Pattern problem.Also mention the worst case running time for this operation. What is evaluation and interpolation of Polynomials.n) { s=0. What do you mean by dynamic programming . 69. 82. 77.. Explain 0/1 knapsack problem using Dynamic Programming.30.X5 )of length 20. Write an algorithm to delete an element from a linked list . 76. Define Algorithm and also explain the different criterion that all algorithms must satisfy. Explain why we use a asymptotic notation . 70.j]:= a[i.j]. Explain the various path traversal techniques with example. Explain the tree traversal techniques. 86. Explain the connected and Biconnected components in Graphs..0.Also define the following notations (i)Big Oh (ii) Omega (iii)Theta 85. } 74. Using suitable example explain straightforward evaluation of polynomials 78. Explain algorithm for evaluating a polynomial in coefficient exponent form. 83.

Design & Analysis of Algorithms with example Solve 4 Queens Problem using Backtracking What is dynamic Programming.Course File . Solve 0/1 knapsack Problem using Dynamic Programming. 19 | P a g e .(you need to give a . 1 105)give pictorial representation of each pass.Explain any 2. 15. State and write Knapsack problem using Greedy Method 109)Give State space representation for 4 Queen's problem. 106)What is criterion function and solution space of Backtracking? Explain and solve four Queen's problem using Backtracking 107)Explain in detail various Set algorithms 108)What is Greedy method? Give general algorithm for it. 3.n0) 3n-10=Omega(n) n2-5n-20=Omega(n 2) 113) By taking suitable example explain how the sum of Subset problem can be solved by using Backtracking algorithm design technique.Find the solution of the following salesman problem 104)calculate the number of swaps to sort the following data using bubble sort 5. Explain the algorithm for Quick Sort . -4.Find the solution of the following Traveling Salesperson Problem ?. 93. 92. Solve 0/1 knapsack Problem using Greedy Method. Write short notes on (i) Approximation Algorithms (ii) Combinatorial Algorithms 91. What is Multi Stage Graph Problem What do you mean by sorting . What is Multi Stage Graph Problem? How does dynamic problem help in solving it 101. 114) Explain the following algorithm design techniques . Explain evaluation and interpolation with example. 94.c. 102)Write an algorithm to find nth minimum and maximum element using divide and conquer strategy 103)What is Traveling Salesperson Problem?.Initial arrangement of tiles is given below 111) Prove using the formal definition of Big O. Number the nodes as in (i)DFS (ii)BFS 110) Solve 15 Puzzle Problem using Branch and Bound . 95.n0) 5n-3=O(n) 2n2+3n+20=O(n 2) 112) Prove using definition of Omega( you need to give a .What are various sorting Techniques . 98.c..On what input does Quick Sort exhibit its worst case behavior 100. Differentiate between Deterministic and Non Deterministic Algorithms. 97. What is NP Hard and NP Complete ?Explain with example. 96. -10. 99. 2. 0..

25.35.m=20 (P1. (L1.15.Design & Analysis of Algorithms (i)Backtracking (ii)Branch and Bound (iii)Dynamic Programming (iv)Divide and Conquer 115) Write and explain the algorithms for Disjoint Set Union if we are given two sets Si and Sj 116) Define Knapsack problem..(P1. 127) Discuss advantages and disadvantages of each 128) What is data structure ?Explain various data structures with examples 129) Write algorithm for Quick Sort using divide and Conquer .2. Explain multistage Graphs using dynamic Programming 133) What are Strings.Find Optimal Merge pattern for 10 files whose lengths are 28..53.5.P4)=(100.11 120) Obtain a set of Optimal Huffman Codes for the messages(M1.91.12.D4)=(2.84.Write the various performance analysis techniques of Algorithm .Represent the relation between them.Draw the decode tree for this set of codes.10) 117) Define Job Sequencing with Deadlines . Solve the following using Knapsack Problem n=3. Show that clique optimization reduces to clique decision problem.5.Solve the following problem using Job Sequencing with Deadlines: n=4.12.. Differentiate between them..15) (W1.M7)with relative frequencies (q1..P3)=(24.. 125) What are approximation Algorithms.15. Prove that P is a subset of NP.L2. 124) What is Clique Decision Problem. 126) What is Algorithm . Define absolute approximation and Eapproximation with example.10. 121) Define the Traveling Salesperson Problem .10..7..W2.L3)=(5. 130) What is Divide and Conquer algorithm..P2.P3. 123) Define NP Hard and NP Complete . 20 | P a g e . Use this algorithm to find maximum and minimum from a given array 131) Write an algorithm for Merge Sort using Divide and Conquer. 132) What do you mean by dynamic programming.1) 118) Define Optimal Storage on Tapes. Solve the following using this technique: n=3.Solve problem using TSP where the edge lengths are given as: 0 10 15 20 5 6 8 0 13 8 9 0 9 10 12 0 122) What do you mean by deterministic and Non Deterministic Algorithms.Course File .. What are various String Algorithms.32.q7)=(4.D3.10.W3)=(18.8. Explain any two of them. Write example for each of them.20).27) (D1.3.3) 119) Define Optimal Merge Pattern .P2.1.D2.

Solve 15-puzzle problem 146) Define the following LC Search FIFO Branch and Bound LC branch and Bound 147) Define Principle of Optimality .Also explain the following notations: Big O Omega Theta 136) What do you mean by complexity of an algorithm .Explain how does it holds on the following problems: knapsack Optimal Merge Pattern Shortest Path 21 | P a g e .Course File .Design & Analysis of Algorithms 134) Explain 0/1 knapsack problem using any two techniques you know 135) Explain asymptotic notations . Solve 8 Queens problem by backtracking 141) Explain various search techniques for trees 142) Explain various search techniques for graphs 143) How sum of subset problem is solved by Backtracking 144) What is graph coloring.Show that a graph is 4 color able 145) What do you mean by Branch and Bound. Explain it with example .Define time and space complexity with examples 137) Explain various traversal techniques for trees 138) Explain various traversal techniques for graphs 139) What is Backtracking. Explain various problems solved by backtracking 140) What is Backtracking.

Course File .Design & Analysis of Algorithms UNIVERSITY QUESTION PAPERS 22 | P a g e .

What is the time complexity of Merge Sort? g). (ii) Inorder. h). What are Union Find Problems? i). Dec-07) Section-A 1). 23 | P a g e . Section-C 7). (a) Consider a Binary tree with names attached to the vertices. What are position trees? Describe using examples. determine all occurrences of y in x. Describe the Dynamic Programming algorithm for computing the minimum cost order of multiplying a string of n matrices M1 x M2 x M3……. (b) Give an example of NP-Complete Problem. 4). a).x Mn.Course File .Design & Analysis of Algorithms Design and Analysis of Algorithms (CS-307. Give an example of Dynamic Programming Approach. Write an algorithm to print the names in (i) Pre-order. What do you understand by Algorithm Evaluation? b). What is NP Complete Problem? Section-B 2). What are NP. e). (iii) Post order. Describe a path in an undirected graph. Explain the relationship between Turing Machine and RAM models. What is Pattern Matching? j). Explain the algorithm of a non-deterministic finite automation. 5). What are Stored RAM model? d). 9). NP Hard and NP complete problems? Explain by giving an example of each. (a) What are string matching algorithms? (b) Given a text string x and pattern string y. (b) How binary tree can be used for searching an element? Explain. (a) Explain the algorithm for Fast disjoint set union algorithm. f). What is asymptotic time complexity? c). Define post order traversal of a tree. 3). 8). 6).

Design & Analysis of Algorithms Roll No. b) What is re-entrantp rogram? c) What is Akermann's function give example? d) What is the basic principal of Divide and Conquer? e) What is stable sorting? f) Differentiate between Top-down and Bottom-up approach. 3) Attempt any Tlvo questionsf iom Section.A QI) (10x2 =20) a) Define Big Omega Notation and Little Omega Notation . Total No.A is Compulsory.T he numberso n the edgesa re the weights' Q7) Compare general and recursive back tracking methods and also write a algorithm to find all Hamiltoman cycle for graph using back tracking method.C (2x10=20) Q6)Find the shortest path from node 1 to all vertices of the graph given below' Show all the intermediates teps. Q9) Write short note on following: (a) Techniques for algebraic problems (b) Polynomial time algorithm. Q8) Deftne a minimum spanning tree. Section. (Sem. 24 | P a g e . of Questions : 9 Total No.B. Maximum Marks : 60 Section . – 5th) DESIGN AND ANALYSIS OF ALGORITHMS (CS .Course File .C. j) What is an algorithm? Section . g) Define recurrencere lation.307) Time : 03 Hours Instruction to Candidates: 1) Section . Write Prim's algorithm to find minimum spanning tree. i) Namet hreec onditionsu nderw hich sequentiasl earcho f a list is preferable to binarv search.B (4x5=20) Q2)Differentiate betu'een N-P hard and N-P complete problems with example' Q3)Find lower bound for multiplying m x n matrix with n x 1 vector' Q4)Write a algorithm for Quick sort and complexity' Q5)Explain how the knapsack problem can be solved using branch and bound algorithms.Tech. h) Given an example of an algorithm which is infinite in nature. of Pages : 02 Paper ID [A 0467] (Please fill this Paper ID in OMR Sheet) B. 2) Attempt any Four questionsf rom Section.

3) Attempt any Two questions from Section .C (2 x 10:20) Q6) Sortt he following usingG eapsortte chniqueL :'-5. Section . (b) Using Knuth-Marries-pratt algorithm find whether the pattern P : <0010> is in the text T . 2) Attempt any Four questions from Section .8.100.B (4x5:20) Q2) Does greedy algorithm always give an optimal solution?Give arguments to support your answer. Support your arguments with an example and analysis.11.4.A is Compulsory.Design & Analysis of Algorithms Roll No.20. Section . 25 | P a g e .3.< 11 010 00010 10001010100 010 >.307 Paper ID IA 0467l Time : 03 Hours Maximum Marks : 60 Instruction to Candidates: 1) Section.C. j) State the knapsack problem using branch and bound technique. Write Kruskal's algorithm to find minimum Spanning tree.Course File . of pages: 02 DESIGN AND ANALYSIS OF AI-GORITHMS SUBJECT CODE : CS . Q3)Among Merge sort. Q8) What do you mean by dynamic programming?Explain assignment problem with example. Q5) What aret he featureso f brancha nd bounda lgorithms?D iscussi n detail. Insertion sort and Bubble sort which sorting technique is the best in worst case.B.A QI) (10x2=20) a)Define Big oh Notation (O) and Little oh Notarion (o). i) Name the three conditions under which sequential search of a list is preferable to binary search. Q9) Define a minimum spanning tree.9. g) What is a solution space in the backtracking? h) Given an example o f an algorithm which is infinite in nature. Q4) Write a recursive algorithm for Binary search Tree and complexity.3>0. of Questions: 09 Total N o. I b) What is re-entrant program? c) What is NP complete? d) What are row major and column major ordering? e)What is the purpose ofAVL Tree? f)Differentiate between space complexity and Time space tradeoff. Q7) (a) What are approximation algorithms?Explain approximation vertex cover. TotalN o. Section .

.C. Total No. .... Section .Course File . 2) Attempt any Four questions from Section .. NP-hard and NP-complete problems.20) Q2) Differentiate between deterministic and non-deterministic algorithms? Q3) Explain how the knapsack problem can be solved using branch and bound algorithms.A is Compulsory. Q6) Explain the algorithm of a non-deterministic finite automation. 3) Attempt any Two questions from Section . of Questions : 09 TotalN o. Tech... Q4) Explain the backtracking problem with the help of suitable example? Q5) Explain how to validate and analyze the algorithms. Section-C (10x2-20) Q7) Explain in detail basic concepts of P.. Q8) Explain in detail the structure of string storage. of Pages: 02 B. Maximum Marks : 60 (10x2-20) Section – B (4 x.. 26 | P a g e .. NP. j) Give an €xample of an algorithm which is infinite in nature. h) What do you mean by worst case analysis? i) Define Non-deterministic algorithm.Design & Analysis of Algorithms Roll No..B..( Sem.A' QI) a) Explain the term the order of complexity.. Q9) What do you mean by complexity of an algorithm? Define time and space complexity with examples. lines and characters in a given text...r. d) Explain the asymptotic notation.5 .307 Paper ID I IA0467l [Note: Pleasefi ll subjectc odea nd paperI D on OMRI Time : 03 Hours Instruction to Candidates: 1) Section .. b) Give the general characteristics of greedy algorithm" c) Describe the general principle of Divide and conquer. Design an algorithm which finds number of words.... e) What is re-entrant program? 0 What is stable sorting? g) Differentiate between NP-Hard and Np-Complete..5th) DESIGN AND ANALYSIS OF ALGORITHMS SUBJECT CODE : CS .

Course File .VOICE QUESTION 27 | P a g e .Design & Analysis of Algorithms VIVA .

Prefix Notation: ^ . 2.DE + FG Postfix Notation: AB + C * DE . What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms? Polish and Reverse Polish notations. A binary tree with n nodes has exactly n+1 null nodes. A binary tree with 20 nodes has 21 null branches? Let us take a tree with 5 nodes (n=5) Null Branches It will have only 6 (ie. 6.* +ABC . Natural merging. Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations. 4. Distribution of Initial runs. 5. How many different trees are possible with 10 nodes ? 1014 28 | P a g e .. In general.5+1) null branches.Design & Analysis of Algorithms 1. Sorting is not possible by using which of the following methods? (a) Insertion (b) Selection (c) Exchange (d) Deletion (d) Deletion.Course File . Polyphase sort.FG + ^ 3. What are the methods available in storing sequential files ? Straight merging.

In the given binary tree. 15. In general: There are 2n-1 nodes in a full binary tree. 23 .Design & Analysis of Algorithms For example. By the method of elimination: Full binary trees contain odd number of nodes. With 13 nodes you can form a complete binary tree but not a full binary tree. So there cannot be full binary trees with 8 or 14 nodes. What is the type of the algorithm used in solving the 8 Queens problem? Backtracking 9.3 = 5) trees. All full binary trees are complete binary trees but not vice versa 10. Note: Full and Complete binary trees are different. there exist 2n-n different trees. 7.Course File . 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree? 15. using array you can store the node 4 at which location? 1 2 4 5 3 29 | P a g e . consider a tree with 3 nodes(n=3). it will have the maximum combination of 5 different (ie. 13. There are 8. so rejected. In tree construction which is the suitable efficient data structure? (a) Array (b) Linked list (c) Stack (d) Queue (e) none (b) Linked list 8. So the correct answer is 15. i ii iii iv v In general: If there are n nodes.

one from start of the original array to the pivot position-1 and the other from pivot position+1 to end. 65 70L 75 80 85 60 55 50 45R Since pivot is not yet changed the same process is continued after interchanging the values at L and R positions 65 45 75 L 80 85 60 55 50 R 70 65 45 50 80 L 85 60 55 R 75 70 65 45 50 55 85 L 60 R 80 75 70 65 45 50 55 60 R 85 L 80 75 70 When the L and R pointers cross each other the pivot value is interchanged with the value at right pointer. The values at the left pointer and right pointer are indicated using L and R respectively. Sort the given values using Quick Sort? 65 70 75 80 85 60 55 50 45 Sorting takes place from the pivot value. this is marked bold. 30 | P a g e .Course File . If the pivot is changed it means that the pivot has occupied its original position in the sorted order (shown in bold italics) and hence two different arrays are formed.Design & Analysis of Algorithms At location 6 1 2 3 4 5 Root LC1 RC1 LC2 RC2 LC3 RC3 LC4 RC4 where LCn means Left Child of node n and RCn means Right Child of node n 11. which is the first value of the given elements.

Of the following tree structure. draw the DFS and BFS? The given graph: A X H E G P M J Y BFS: DFS: AXGHPEMYJ AXHPEYMJG 13. For the given graph. 45 50 55 60 65 70 75 80 85 12. efficient considering space and time complexities? (a) Incomplete Binary Tree (b) Complete Binary Tree (c) Full Binary Tree 31 | P a g e . which is.Course File .Design & Analysis of Algorithms 60 L 45 50 55 R 65 85 L 80 75 70 R 55 L 45 50 R 60 65 70 R 80 L 75 85 50 L 45 R 55 60 65 70 80 L 75 R 85 In the next pass we get the sorted form of the array.

By the method of elimination: Full binary tree loses its nature when operations of insertions and deletions are done. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized. What is a spanning Tree? A spanning tree is a tree associated with a network. Convert the given graph with weighted edges to minimal spanning tree. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes? No. So complete binary tree is the better one since the property of complete binary tree is maintained even after operations like additions and deletions are done on it. All the nodes of the graph appear on the tree once. 1 410 2 600 612 2985 1421 3 310 200 5 400 4 the equivalent minimal spanning tree is: 1 3 612 310 4 200 5 410 2 32 | P a g e . extra storage is required and overhead of NULL node checking takes place. 15. 16. But it doesn’t mean that the distance between any two nodes involved in the minimumspanning tree is minimum. 14. Minimal spanning tree assures that the total weight of the tree is kept at its minimum. For incomplete binary trees.Course File .Design & Analysis of Algorithms (b) Complete Binary Tree.

Course File .Design & Analysis of Algorithms TUTORIAL SHEETS 33 | P a g e .

What is time complexity ? 5. In the following Graph .Explain with the help of suitable algorithms. 4. 10.list all substrings of W. The order of complexity of Binary Search in Best case is -----in the average case is -----in the worst case is -------9.Course File .Also explain the following notations: Big O Omega Theta 7.find out the shortest distance of all the nodes from the node A . 20 . 8. 18. 7. What is the worst case running time of algorithm to delete each element from the linked list? 4. 3.Design & Analysis of Algorithms TUTORIAL SHEET . What is recursion?What are its drawbacks? 8. 2. What is criterion function in backtracking? What is solution space for backtracking problem? Explain by taking sum of subset as a problem 34 | P a g e . What is space complexity? 6.2 1. If W= MNOP. Write an string processing algorithm to identify whether a particular sequence of character is in string or not. 16. What are the advantages of dynamic programming over greedy method? What are the conditions under which backtracking can be used? What is solution space in Backtracking Techniques ? How will Merge Sort sort the 6 numbers: 40.62. What is the worst case running time of Quick Sort? 3. Explain the backtracking Problem with 4 Queens on a 4*4 chess board. 6. by divide and conquer technique. 9. Is 2n+1=O(2n)? 2. 10.1 1. Explain asymptotic notations . What are the various methods or techniques in which various algorithms can be expressed? TUTORIAL SHEET . Give the definition for 0/1 knapsack problem. 5. Define the term Divide and Conquer. 10.

3) 10.27) (D1.15.2.D3.L2. Differentiate between Deterministic and Non Deterministic Algorithms.P2.(P1. Define Prim's and Kruskal Algorithms What is NP Hard and NP Complete ?Explain with example. Define Optimal Storage on Tapes. Solve 15 Puzzle Problem using Branch and Bound . Define Job Sequencing with Deadlines .D2.Course File .P4)=(100.Solve the following problem using Job Sequencing with Deadlines: n=4.10. 4.1) 9.Design & Analysis of Algorithms TUTORIAL SHEET – 3 1.Initial arrangement of tiles is given below 8. What is Clique Decision Problem.L3)=(5. Explain in detail various Set algorithms 7. (L1.D4)=(2. 5. What is Multi Stage Graph Problem? How does dynamic problem help in solving it Write short notes on (i) Approximation Algorithms (ii) Combinatorial Algorithms 6. Solve the following using this technique: n=3.P3. 3. 2.10.1. 35 | P a g e . Show that clique optimization reduces to clique decision problem.

- Techinical Terms
- Evaluate Algorithms
- OOPS Lab Manual
- Merge Sort
- Theory of Computation Aqa Ocr
- boca
- 210CT Revision Notes
- DAA Course File
- IRJET-A Review on Complexity Results for Some Eigenvector Problems
- Data Structure - Lecture 1 Introduction]
- Lecture 2
- Data Structures
- Computational Geometry Methods and Applications - Chen
- Cse-IV-Design and Analysis of Algorithms [10cs43]-Notes
- Ps1 Solution(VERY IMP)
- Computer science C++
- daa
- IP CSE 205
- Python Lab Manual Final
- n Jobs and M- Machine Problem
- DS Programming Assignement
- 1 Introduction
- ch10
- Icalp99Full
- S.Y.B.Sc.(Computer Science) Practical Examination
- 1998 Galve-FrancesEtAl AlgorithmDesignByPatterns
- Ads a Lab Manual
- A Novel Sorting Technique to Sort Elemen
- Doc
- B.tech MDU Syllabus (CSE)

- Ms Excel Mcq
- RDBMS_Notes.doc
- Rdbms Notes
- usbvirusfolderundelete-111110021717-phpapp02.pdf
- Multimedia-Systems_final.doc
- Virus creation for USB .pdf
- Statistics Tutorial
- Relational Algebra New
- MS Word 2007 Practical Notes_08!09!2014
- evolution of Computer networks.pdf
- SM Tutorial Sheet-1
- SM Tutorial Sheet-2
- Systems Multimedia- A Summary
- Relational Databse Notes.doc
- Perspectives on Big Data
- NetEye
- 5.pdf
- Net Mag Paper
- 0112ijassn01.pdf
- NSDI07.pdf
- sensors-wsn
- A Variant of LEACH for WSNs
- Energy Aware Routing_WSN
- Integrity Enhancement in Wireless Sensor Networks
- rm_question_bank_iisem.pdf
- Gateway-Based Energy-Aware Multi-Hop Routing Protocol for WSNs
- AODV & DSR
- 0811.4349.pdf
- Routing_WSN
- RM_Intro.pdf

Sign up to vote on this title

UsefulNot usefulRead Free for 30 Days

Cancel anytime.

Close Dialog## Are you sure?

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

Loading