Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Similar documents
L.J. Institute of Engineering & Technology Semester: VIII (2016)

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

DESIGN AND ANALYSIS OF ALGORITHMS

5105 BHARATHIDASAN ENGINEERING COLLEGE

END-TERM EXAMINATION

D.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1.

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

R13 SET - 1. ''' '' ''' ' blog: anilkumarprathipati.wordpress.com. Code No: RT32054

Contents. 1 Introduction. 2 Searching and Traversal Techniques. Preface... (vii) Acknowledgements... (ix)

INSTITUTE OF AERONAUTICAL ENGINEERING

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

2. (a) Explain when the Quick sort is preferred to merge sort and vice-versa.

CSci 231 Final Review

Model Answer. Section A Q.1 - (20 1=10) B.Tech. (Fifth Semester) Examination Analysis and Design of Algorithm (IT3105N) (Information Technology)

UNIT 1 BASICS OF AN ALGORITHM

( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

Lecture 3. Brute Force

IV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation

Midterm solutions. n f 3 (n) = 3

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: CS6402- Design & Analysis of Algorithm Year/Sem : II/IV UNIT-I INTRODUCTION

CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li

Design and Analysis of Algorithms

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

Greedy algorithms is another useful way for solving optimization problems.

CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

Lecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Introduction to Algorithms I

CSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

DESIGN AND ANALYSIS OF ALGORITHMS

ESO207A: Data Structures and Algorithms End-semester exam

Algorithm Design Techniques part I

Review for Midterm Exam

Algorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48


Notes on Minimum Spanning Trees. Red Rule: Given a cycle containing no red edges, select a maximum uncolored edge on the cycle, and color it red.

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

Topic Analysis PART-A

CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK

6. Algorithm Design Techniques

looking ahead to see the optimum

FINAL EXAM SOLUTIONS

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Chapter 3 Dynamic programming

Theorem 2.9: nearest addition algorithm

Data Structures and Algorithms

Plotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1

Introduction to Data Structure

15.4 Longest common subsequence

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS

CS-6402 DESIGN AND ANALYSIS OF ALGORITHMS

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

n 2 ( ) ( ) + n is in Θ n logn

TOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

DATA STRUCTURES AND ALGORITHMS

Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu

Lecture Summary CSC 263H. August 5, 2016

Unit-5 Dynamic Programming 2016

Data Structures and Algorithms. Part 2

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

Data Structures and Algorithms Chapter 2

Optimization II: Dynamic Programming

Virtual University of Pakistan

( ) n 3. n 2 ( ) D. Ο

Practice Problems for the Final

Week 11: Minimum Spanning trees

Dynamic Programming Homework Problems

Dr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions

1. To reduce the probability of having any collisions to < 0.5 when hashing n keys, the table should have at least this number of elements.

Multiple Choice Question. Unit-1 Introduction

CS6402 Design and Analysis of Algorithm. 2 Marks Question & Answer UNIT I INTRODUCTION

Algorithm Analysis. Jordi Cortadella and Jordi Petit Department of Computer Science

COE428 Lecture Notes Week 1 (Week of January 9, 2017)

Multiple-choice (35 pt.)

Algorithms and Data Structures

Framework for Design of Dynamic Programming Algorithms

Here is a recursive algorithm that solves this problem, given a pointer to the root of T : MaxWtSubtree [r]

CAD Algorithms. Categorizing Algorithms

CS521 \ Notes for the Final Exam

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Algorithms and Theory of Computation. Lecture 2: Big-O Notation Graph Algorithms

9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

O(n): printing a list of n items to the screen, looking at each item once.

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

Greedy Algorithms CHAPTER 16

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Chapter 6. Dynamic Programming

( D. Θ n. ( ) f n ( ) D. Ο%

Name: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.

Transcription:

Class: V - CE Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology Sub: Design and Analysis of Algorithms Analysis of Algorithm: Assignment 1. Describe the method for analyzing an algorithm. What do you mean by best case, average case, and worst case time complexity of an algorithm? 2. Define the term Algorithm and Complexity of Algorithm. 3. What does O (1) mean? What does Ω (1) mean? 4. Define O (big oh) notation mathematically. 5. Define time and space complexity. 6. Which method should be used for calculating Fibonacci sequence? Recursive or Nonrecursive? Why? 7. Devise an algorithm which maintains telephone directory of your friends. List the names of your friends in the lexicographical order. 8. Consider the following list of elements: 70, 80, 40, 50, 60, 11, 35, 85, 2 Sort the above list using Merge sort, Bubble sort, and Insertion sort. In above techniques which sorting technique is the best in worst case? Support your argument with an example and analysis. 9. Define the following terms: a) Big oh Notation (O) b)big theta Notation (Θ) c) Big Omega Notation (Ω) d) Little oh Notation (o) e) Little Omega Notation (ω) 5. Find the Big oh (O), Big Theta (Θ), Big Omega (Ω), Little oh (o), and Little omega (ω) Notation for the following functions. a) f(n) = 14 * 6 + 25 b)f(n) = 6n + 10 * 20 c) f(n) = 69n 2 + n + 35 6. Prove that following are Incorrect Bounds. a) 7n 3 + n O(n 2 ) b) 7n + 3 O(1) c) 7n 3 + n 2 Ω(n 4 ) d) 7n + 3 Ω(n 2 ) 7. Prove that the following are the loose bounds. a) 7n 3 + n 2 = O(n 4 ) b) 7n + 3 = O(n 2 ) d) f(n) = 70n 3 + 35n 2 + 45 e) f(n) = 3*2 n + 58n 2 + 39 c) 7n3 + n 2 = Ω(n 2 ) d) 7n + 3 = Ω(1) 8. Prove if f(n) = a m n m + a m-1 n m-1 + + a 1 n + a 0, and a m >0, then f(n)=θ(n m ). e) 7n + 3 Θ(n 4 ) f) 7n + 3 Θ(n 2 ) 9. Illustrate the operation of INSERTION-SORT on the array A = (31, 41, 59, 26, 41, 58). V-CE-DAA-Assignment 1

10. If f(n) and g(n) be such that lim / exists, then function f Θ (g), if lim / = C. Prove for some constant c that 0 < c <. 11. Arrange the following growth rates in the increasing order: O (n 3 ), O (1), O (n 2 ), O (n log n), O (n 2 log n), Ω (n 0.5 ), Ω (n log n), Θ (n 3 ), Θ (n 0.5 ) 12. Write the INSERTION-SORT procedure to sort decreasing order. 13. Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n 2 steps, while merge sort runs in 64n lg n steps. For which values of n does insertion sort beat merge sort? 14. What is the smallest value of n such that an algorithm whose running time is 100n 2 runs faster than an algorithm whose running time is 2n on the same machine? 15. Consider the searching problem: Input: A sequence of n numbers A = a1, a2,..., an and a value v. Output: An index i such that v = A[i] or the special value NIL if v does not appear in A. Write pseudo code for linear search, which scans through the sequence, looking for v. using a loop invariant; prove that your algorithm is correct. Make sure that your loop invariant fulfills the three necessary properties. 16.Consider the problem of adding two n-bit binary integers, stored in two n-element arrays A and B. The sum of the two integers should be stored in binary form in an (n + 1)-element array C. State the problem formally and write pseudo code for adding the two integers. 17.Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[1]. Then find the second smallest element of A, and exchange it with A [2]. Continue in this manner for the first n-1 elements of A. Write pseudo code for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the first (n - 1) element, rather than for all n elements? Give the best-case and worst-case running times of selection sort in Θ-notation. 18. How many elements of the input sequence need to be checked on the average, assuming that the element being searched for is equally likely to be any element in the array? How about in the worst case? What is the average-case and worst-case running times of linear search in Θ-notation? Justify your answers. 19. Use mathematical induction to show that when n is an exact power of 2, the solution of the recurrence 2 2, 2 2, 2, 1, 20. Insertion sort can be expressed as a recursive procedure as follows. In order to sort A [1.. n], we recursively sort A[1.. n -1] and then insert A[n] into the sorted array A[1.. n - 1]. Write a recurrence for the running time of this recursive version of insertion sort. 21. Write pseudo code, either iterative or recursive, for binary search. Argue that the worst-case running time of binary search is Θ (lg n). 22. Show that the solution to T (n) = 2T ( n/2 + 17) + n is O (n lg n) using substitute method. 23. Solve the recurrence 2 1 by making a change of variables. 24. Draw the recursion tree for T (n) = 4T ( n/2 ) + n, and provide an asymptotic bound. 25. Show that if a DECREMENT operation were included in the k-bit counter example, n operations could amortize cost as much as Θ (n k) time. V-CE-DAA-Assignment 2

26. Use the master method to give tight asymptotic bounds for the following recurrences. a) T (n) = 4T (n/2) + n. b) T (n) = 4T (n/2) + n2. c) T (n) = 4T (n/2) + n3. 27. Explain the principle of optimality. 28. The running time of an algorithm A is described by the recurrence T (n) = 7 T (n/2) + n 2. A competing algorithm A has a running time of T (n) = a T (n/4) + n2. What is the largest integer value for such that A is asymptotically faster than A? 29. Prove that the Towers of Hanoi problem with (n) rings cannot be solved with fewer than 2 n -1 movements of rings. 30. Use a recursion tree to solve the recurrence T (n) = T (α n) + T ((1-α) n) + n, where α is a constant in the range 0 < α < 1. 31. Write a heap sort algorithm to sort n items in an array of size n. Analyse the algorithm. 32. Consider an array T [1 n] and an integer k between 1 and n. Use simplification to design an efficient to interchange the first k and the last n-k elements of T without making use of an auxiliary array. Analyse the running time of your algorithm. 33. Write an efficient algorithm to find exponentiation x = a n, where a and n are integers. Give detailed analysis. What is the worst case behaviour? 34. Write an efficient algorithm using heaps to solve shortest path problem using Dijkstra method. Give one example of it. What is the worst case asymptotic behaviour? 35. Analyze the Quick-sort in average and worst case. Derive the recurrence for average case and solve it. 36. The expected number of comparisons needed to insert n random elements into an initially empty binary tree is O (n log n) for n >= 1. Justify. 37. What is amortized analysis? What is the usefulness of it? 38. Define asymptotic notations. 39. Give heap sort algorithm and prove that time complexity of heap sort is Θ (n log n). 40. Write an efficient algorithm to find exponentiation x = a n, where a and n are integers. Give detailed analysis. What is the worst-case behaviour? 41. Recursive version of insertion sort works as follows: Sort (n-1) elements recursively and then insert n th element at proper position. Write recurrence relation for this algorithm and solve it. 42. Define the terms loose bound and tight bound. 43. Explain the term accounting trick. 44. Write down the algorithm to find minimum of N numbers and find its complexity. 45. What do you mean by recurrence relation? 46. State Master method with suitable example. 47. What do you prefer efficient hardware or efficient algorithm. Justify your answer with example. 48. Explain the advantage of analytical frame work of algorithm analysis over practical approach of algorithm analysis. 49. What do you mean by polynomial time complexity and logarithmic complexity? Which one is higher? 50. Write down a sequential algorithm to find an element x in T (1 n) array sorted into non decreasing order. What will be the best case and worst case time complexity? Write down an efficient algorithm that will speed up the search of an element. Analyse the complexity. V-CE-DAA-Assignment 3

Divide and conquer Algorithm: 51. Illustrate the operation of merge sort on the array A = {3, 41, 52, 26, 38, 57, 9, 49}. 52. Write the complete Merge Sort procedure. 53. Describe a Merge sort algorithm that is designed based on the divide-and-conquer technique. Give a suitable example to illustrate the algorithm. Compute the worst-case computational complexity of the algorithm. 54. Consider the classical merge sort algorithm, where T [1 n] will be separated in two half-size arrays for the purpose of merge sorting. Now rather than that we might choose to separate T into three arrays of size n 3, (n+1) 3 and (n+2) 3, to sort each of those recursively, and then to merge the three sorted arrays. Give the more formal description of this algorithm and analyse it. 55. Suppose we want to multiply 12345 with 54321. Give stepwise computations using divide and conquer algorithm (a) which performs three almost half size multiplications (b) which performs five almost 1/3 size multiplications; to achieve this efficiently. Exactly how many multiplications required doing this in each case? Which is the better method out of (a) and (b)? 56. Suppose we want to find (12345) 3. Give the stepwise computations to find it most efficiently using divide and conquer paradigm. (Hint: Use the algorithm that computes a n in time complexity Θ (m log 3 n log 3 ) where m is the number of digits of a. 57. Show with an example that how a Divide-and-Conquer method helps in multiplying two numbers efficiently. 58. Give divide and conquer algorithm to find a n efficiently and analyse the algorithm. 59. Write down the recurrence for general analysis of matrix multiplication using divide-and-conquer algorithms. What will be the complexity for same? 60. Two large numbers are to be multiplied. Design an effective algorithm with divide and conquer approach. Also Analyse it. Greedy Algorithm: 61. The problem of scheduling several competing activities that require exclusive use of a common resource, with a goal of selecting a maximum-size set of mutually compatible activities. Suppose we have a set S = {a 1, a 2,..., a n } of n proposed activities that wish to use a resource, such as a lecture hall, which can be used by only one activity at a time. Each activity a i has a start time s i and a finish time f i, where 0 s i < f i <. If selected, activity a i takes place during the half-open time interval [s i, f i ). Activities a i and a j are compatible if the intervals [s i, f i ) and [s j f j ) do not overlap (i.e., a i and a j are compatible if s i f j or s j f i ). The activityselection problem is to select a maximum-size subset of mutually compatible activities. For example, consider the following set S of activities. Find possible subset of mutually compatible activities using Greedy method. i 1 2 3 4 5 6 7 8 9 10 11 Si 1 3 0 5 3 5 6 8 8 2 12 Fi 4 5 6 7 8 9 10 11 12 13 14 62. Consider the single machine scheduling problem where we are given a set of T of tasks specified by their start time and end times. We wish to maximize the number of tasks that this single machine performs. Design a greedy algorithm for this single machine scheduling problem and analyse the running time of your algorithm. Suppose you are given a set of tasks specified by pairs of the start times and finish times as T={(1,4), (1,3), (1,2), (2,4), (3,7), (4,8), (5,6), (6,8), (7,9)}. Solve the task scheduling problem for this set of tasks using your greedy algorithm. 63. Consider a scheduling problem where the 6 jobs have a profit of (10,34,67,45,23,99) and corresponding deadlines (2,3,1,4,5,3). Obtain the optimum schedule. What is the time complexity of your algorithm? Can you improve it? V-CE-DAA-Assignment 4

64. What are the characteristics of Greedy algorithm? 65. You are given a set of N jobs associated with each of i is a processing time t i and a deadline d i by which it must be completed. A feasible schedule is a permutation of the jobs such that is the jobs are processed in that order, and then each job finishes by its deadline. Define a greedy schedule to be one in which the jobs are processed in non-decreasing order of deadline. Suppose J is a set of k jobs. Show that set J is feasible if and only if the sequence 1, 2 k is feasible. 66. Give greedy algorithm for solving TSP for n cities. What are the worst case and best-case time complexities? 67. Write down a greedy algorithm to solve making a change problem. 68. What do you mean by minimum spanning tree? 69. What do you mean by fractional Knapsack problem? 70. Suppose we live in a country where following coins are available: Rs. 1, Rs. 2, Rs. 3, Rs 4. Our problem is to pay an amount of Rs. 10 using smallest possible number of coins. Write down the greedy algorithm for the given problem. What be the solution for mentioned problem? 71. A system has to serve n customer. The service time of each customer is known in advanced. Suppose customer i will take T i time to serve. The aim of system is to minimize the average waiting time of customer. Prove that greedy algorithm always gives optimal solution to above problem. 72. Use greedy method to fill the knapsack with maximum profit for given knapsack capacity W. W=20, (p 1, p 2, p 3 ) = (25, 24, 20), (w 1, w 2, w 3 ) = (18, 15, 10) Solve the given problem using Binary (0/1) knapsack as well as fractional knapsack. Dynamic Programming: 73. Consider the alphabet = {a, b, c}. The elements of have the following multiplication table, where the rows show the left-hand symbol and the columns show the right-hand symbol. a b c a a b a b c b a c a c c Thus a b = b, b a = c and so on. Note that the multiplication defined by thus table is neither commutative nor associative. Find an efficient algorithm that examines a string x = x 1 x 2 x n of characters of and decides whether or not it is possible to parenthesize x in such a way that the value of the resulting expression is a. For instance, if x = b b b b a, your algorithm should return yes because (b (bb)) (b a) = a. This expression is not unique. For example, (b (b (b (b a)))) = a as well. In terms of n (length of string x ) analyse your algorithm. 74. You are supposed to find Z = ABCDE. Dimensions of A, B, C, D and E are given below. Write down the parenthesize equation and number of multiplication for Z so that multiplication in this way cost the least number of scalar multiplications. A: 12 X 7, B: 7 X 19, C: 19 X 12, D: 12 X 10, E: 10 X 13, Z: 12 X 13 75. Given two sequences X [1 m] and Y [1 n], the problem is to find the longest subsequence, which occurs, in both. Write down algorithm and analysis it using dynamic programming. Take suitable example string of at least length 5. 76. How divide and conquer differ from dynamic programming? V-CE-DAA-Assignment 5

77. The input to this problem is a string A = a 1 a 2 a m and B = b 1 b 2 b n. The goal is to convert A into B as cheaply as possible. The rules are as follows. For a cost of 3 you can delete any letter. For a cost of 4 you can insert a letter in any position. For a cost of 5 you can replace any letter by any other letter. For example, you can convert A = abcabc to B = abacab via the following sequence: abcabc at a cost of 5 can be converted to abacbc, which at most of 3 can be converted to abacb, which at cost of 4 can be converted to abacab. Thus the total cost for this conversion would be 12. This may be the cheapest possible conversion. Write dynamic programming algorithm to do this in cheapest way. 78. Three denominations of values 1, 4 & 6 units are available with infinite supplies of each. Write a dynamic programming algorithm to find out min coins required to make an amount of 8 units. What is the time complexity? 79. Suppose that you are given an N X N checkerboard and a checker. You must move the checker from the bottom edge on the top edge of the board according to the following rule: At each step you may move the checker to one of three squares: a) The square immediately above, b) The square that is one up and to the left (but only if the checker is not already in the leftmost column.) c) The square that is one up and one to the right (but only if the checker is not already in the rightmost column.) Each time you move from square x to square y you receive p (x, y) Rupees. You are given p (x, y) for all pairs (x, y) for which a move from x to y is legal. Do not assume that p (x, y) is positive. Given dynamic programming algorithm that figures out the set of moves that will move the checker from somewhere along the bottom edge to somewhere along the top edge while gathering as many rupees as possible. Your algorithm is free to pick any square along the bottom edge as a starting point and any square along the top edge as a destination point in order to maximize rupees gathered along the way. What is the running time of your algorithm? Exploring Graphs: 80. Write an algorithm to solve 0/1 Knapsack problem (Knapsack problem without fractions for items) using Branch and Bound method of exploring implicit directed graph. What is the asymptotic behaviour of your algorithm? Draw the search tree. 81. Design an efficient algorithm to decide whether a given undirected graph G (V, E) contains a cycle of length L. What is the worst case time complexity? Analyse the algorithm. 82. What are spanning tree and minimum spanning tree (MST) of a graph? 83. Consider the undirected graph shown in Figure. Trace the execution of Prim's algorithm as it Exercises finds the minimum-cost spanning tree starting from vertex a. 84. Repeat Exercise using Kruskal's algorithm. V-CE-DAA-Assignment 6

85. Discuss the minimum spanning trees with Kruskal's algorithm & Prim's algorithm Given a Graph G = (V,E,W) where vertices refers to the cities, edges refer to the connection between cities and weight is associated with each edge which represent the cost. Using Greedy algorithm find the minimum cost for TSP. (Show each step clearly.) 86. Consider the following ternary tree and write down the order in which nodes will be visited if tree will be traversed in (a) Depth First Search (b) Breath First Search 87. Explain back tracking design method using knap sack problem. 88. How branch and bound is different from backtracking? 89. What is the worst case time complexity of generating all the permutations of n numbers? (All n numbers are distinct). 90. Use branch and bound method of exploring implicit directed graph to solve the following assignment problem. 1 2 3 4 5 A 11 17 8 16 20 B 9 7 12 6 15 C 13 16 15 12 16 D 21 24 17 28 26 E 14 10 12 11 15 Where A-E is agents and 1-5 are the tasks to be assigned. 91. Use branch and bound to solve the assignment problems with the following cost matrices. 1 2 3 4 A 90 3 45 15 B 82 17 56 9 C 62 24 18 55 D 12 68 20 60 V-CE-DAA-Assignment 7

92. Find all possible solution of 4 queens problem using back tracking. 93. Four types of objects are available, whose weights are respectively 7, 4, 3 and 2 units, and whose values are 9, 5, 3 and 1. We can carry a maximum of 10 units of weight. Objects may not be broken into smaller pieces. Determine the most valuable load that can be carried, using (a) dynamic programming and (b) branch and bound method. 94. Solve the following knapsack problem using back tracking. Capacity of knapsack is 11. Item 1 2 3 4 5 Weight 1 2 5 6 7 String Matching: Profit 1 6 18 22 28 95. Write an algorithm to find the longest common subsequence from two sequences X and Y of size n and m respectively. e.g., X = (A, B, C, B, D, A, B) and Y = (B, D, C, A, B, A). The longest common subsequence is BCBA. What is the worst case time complexity? 96. Compare Brute Force with Rabin Karp algorithm of string matching with example. NP-Completeness: 97. What is class NP? What is class P? Others: 98. Explain the two different types of knapsack problem. 99. You have been given two sets X and Y with cardinality m and n respectively. Your task is to find out value P = x + y s. t., x ɛ X and y ɛ Y. Give most efficient algorithm to do this. What is the worst case time complexity for finding whether: a) Such P exists or not? b) If exist what is the value? 100.The input to this problem is a sequence S of integers (not necessarily positive). The problem is to find the consecutive subsequence of S with maximum sum. Consecutive means that you are not allowed to skip numbers. For example is the input was 12, -14, 1, 23, -6, 22, -34, 13 The output would be 1, 23, -6, 22. Give a linear time algorithm for this problem. 101.A diet is to contain at least 20 ounces of protein and 15 ounces of carbohydrate. There are three types of foods A, B and C available in the market, costing Rs. 2, 1, and 3 per unit respectively. Each unit of A contains 2 ounces of protein and 4 ounces of carbohydrate. Same for B are 3 & 2 respectively. For C are 4 & 2 respectively. How many units of each food should the diet contain so that the cost per unit diet is minimum? 102.Given is the five activities along with their start and finish time. Determine optimum activity schedule result using any appropriate technique. Also write down the algorithm to compute the optimum set of activities. I 1 2 3 4 5 6 7 8 9 10 11 Si 1 3 0 5 3 5 6 8 8 2 12 Fi 4 5 6 7 8 9 10 11 12 13 14 103.How fractional knapsack problem differ from binary knapsack problem? V-CE-DAA-Assignment 8