0% found this document useful (0 votes)
65 views

Algorithm Design Analysis

Uploaded by

Rahim Mia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
65 views

Algorithm Design Analysis

Uploaded by

Rahim Mia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 11
— = ea Department of Computer Science and Engineering fl Mawlana Bhashani Science and Technology University * 2" year 2" semester B.Se. (Engg.) Final Examination, 2016 we Course Code: CSE-2201 Course Title: Algorithm Design and Analysis | Total Marks: 70 Time: 3 hours Answer any Seven 1. a) Define algorithm. What are the eriteria ofa program to be considered as algorithm? 3 b) What is meant by time and space analysis of algorithm? 3 ©) Define best case, worst case and average case complexity. 4 2. a) Write an algorithm for Tower of Hannoi where the no. of disk is 4 b) According to Dynamic Programming determine the length of the shortest path between all 3 pairs of vertices inthe following graph. z ©) Distinguish between dynamic programming and divide and conquer approach. In_which 3 situation dynamic programming is preferred over divide-and-conquer approach? Explain with examples. 3. a) When backtracking solutions are feasible for problem solving? Give an example. b) Determine an LCS of X = (A, B,C, B, D, A, B) and Y = {B,D,C, A,B, A}. ©) What i negative weigh cele? Aply Diase's algorithm wo ind the shortest path fom the 3 | source § to all other vertices inthe following graph. Also describe the limitations of Dijkstra's algorithm. How can you overcome the shortcoming of Dijkstra’s algorithm? 4. a) Consider the following instance of knapsack problem where 3 B= 7,m=15 (0 ,P2sP3--Pr)=(10,5,15,7,8,15,3) and ($1.02, Ws,..W7)=(2,3,6,7,2,4,1).Now caleulate i, All feasible solution ii, Solution using greedy algorithm Page 1 of 3 ee —- b) How do you define greedy choice property? Prove thatthe fractional knapsack pr greedy choice property. Compute the minimum spanning tre for the following figure using Prim’s Algorithm a) Generate the Huffman code for A, B,C, D, E and S where the frequencies are A=12, B=20, 6 |. D=11, E=11, S=13. Conver the text “CSE” to the corresponding Huffman code. bb) Let A'and B be two n=n matrices, The product matrix C=AB is also an nxn matrix, Given(5) 4 oT Al and alt 4 24 fs Perform the matrix multiplication by Strassen’s Matrix Multiplication Algorithm. 5 18) Explain the master method of solving recurrence with example. b) Given a set of 10 activities along with their starting and ending time. 5 fi 3 ar is a0 7 [8 9 10 on ee 3 {sts fe {s [es [iz fi__14 {s_]317_1s [9 | [ur [i2_ [16 ‘Choose the maximum number of activities from the above list so that no two activities overlap each other. ‘8) What is graph coloring? Write the graph coloring algorithm using backtrack technique. Apply 5 graph coloring algorithm for the following figure, b) Let L be an array of n distinct integers. Give an efficient algorithm to find the length of a 5 longest increasing subsequence of entries in L. For example, if the entries are 11,17,5,8.6.4,7.12,3, a longest increasing subsequences is 5,6,7,12. 8) A Two popular graph search algorithm are Breadth First Search and Depth Search Algorithm. 4 Write down the key differences between these two algorithm and other applications of these ‘two algorithms. Apply DFS for the following figure. (5) Page 2 of 3 b °) a) » Solve the magic square having matrix 6%6 also write down the sequence of steps. Let ‘n’ be the number of queens are to be placed on an N*N Chessboard so that the no queens attacks each other that is no two queens are on the same row, column and diagonal. Now write ‘an algorithm to solve the N-Queen problem. Write down Quick-Hull algorithm to find a CONVEX HULL in a geometric plane using Quick Hull method and test it using suitable data. A traveling salesman is getting ready for a big sales tour. Let's consider the directed graph of following figure. Establish dynamic programming solution of TSP. 0 10 14 20 s 0 9 10 6 130 12 2 8,9 0 Page 3 of3 2 20it Gell ot a & ( Department of Computer Science and Engineering ae Mawilana Bhashani Science and Technology University 2" year 2™ semester B.Sc. (Engg.) Final Examination 2017 Course Code: CSE 2201 Course Title: Algorithm Design and Analysis Time: 3 hours Total Marks: 70 (Answer Any SEVEN) I. a) Define algorithm. What are the criteria of a program to be considered as algorithm? 3 'b) Show that the solution of T (n) =T ([n/2]) +1 is O (log n). 3 ©) Demonstrate how divide and conquer technique is used in binary search algorithm to find the 4 key element k= -7 forthe following entries: 15,-5,0,9, 14,23, 46, 54, 83, 13, 123. 141, 144, 151 2. a) Let the data 63, 71, 82, 64, 56, 40, 55, 74 are stored in A{1] to A(8]. Now show each stepto 8 sort those data using Quick sort algorithm. 'b) What will be the best, average and worst case for quick sort technique while sorting N 2 numbers? 3. a) When backtracking solutions are feasible for problem solving? Give an example. 'b) Distinguish between dynamic programming and divide and conquer approach. In which situation dynamic programming is preferred over divide and conquer approach? Explain with 7 examples. ©) What is negative weight cycle? Apply Dijkastra’s algorithm to find the shortest path from 3 the source $ to all other vertices in the following graph. Also describe the limitations of Dijkstra’s algorithm. How can you overcome the shortcoming of Dijkstra's algorithm? 3 Be Nx 4 Find an optimal solution to the fract Number of Objects N: c A ial knapsack instance, 10 5, Maximum weight M= 15 and BR y]woy]s | 3s | 7 8 wl 3 ‘7? 3] 0 Where P, and W; denotes the price and weight of the Fh product respectively 5. a) Show the steps for finding all pair shortest path using Floyd-Warshal algorithm for the 6 following graph, 4 >) Generate the Huffiman code for A,B,C,DsE .M,S,U where the frequencies are A=12, B20, 4 C=4, D=10, E=11,M=13,T=18,S=13,U=16. Convert the text “MBSTU” to the corresponding Huffman code. 6. a) Compute the minimum number of scalar multiplications for the matrix chain multiplication 4 eee >) ° a) ») ° a) ») 9 a) ») You are given Sting [a ]B Je Je [B [C [A |b |e [a [6 [@ IC Pattem/a [B [a [a | = By using Rabin-Karp string matching algorithm find the pattern ‘p’ occurs in “S" and if ‘p does occur then returning position in ‘S* where ‘p’ occurs. Given a directed graph with edge list and weight AB(S), BC(2), AC(4), AD(6), CDG), 3 DB(1), DEG), EB(3), EF(3), FB(4). Construct a min cost arborescence rooted at A. (edge CD(3) means edge is directed from C to D and has weight 3). What is graph coloring? Write the graph J coloring algorithm using backtrack technique. Apply graph coloring algorithm forthe given figure, uw 7 1. 15 Let L be an array of n distinct integers. Give an efficient algorithm to find the length ofa 3 longest increasing subsequence of entries in L. For example, if the entries are 11,17,5,8,6.4,7,12,3, a longest increasing subsequences is 5,6,7,12. Apply the Transitive-Closure algorithm on the 4 graph given in Figure. Show the matrices computed at all stages of the execution of the Transitive Closure algorithm ‘A Two popular graph search algorithm are Breadth First Search and Depth Search Algorithm. Write down the key differences between these two algorithm and other applications of these two algorithms, Apply DFS for the given figure. . : Solve the magic square having matrix 6*6 also write down the sequence of steps. 3 Let ‘n’ be the number of queens are to be placed on an N*N Chessboard so that the no 3 ‘queens attacks each other that is no two queens are on the same row, column and diagonal Now write an algorithm to solve the N-Queen problem. Write down Quick-Hull algorithm to find a CONVEX HULL in a geometric plane using 3 (Quick Hull method and test it using suitable data, A traveling salesman is getting ready for a big sales tour. Let's consider the directed graphof 4 following figure. Establish dynamic programming solution of TSP. ona 7 0 9 10 6 30 2 3 8 20 Define the six classes of problems: P, Co-P, NP, Co-NP, NP- complete and NP-hard. Show 3 that vertex cover is a NP-Complete. oo J ‘iS ann “CF # Department of Computer Science and Engineering Mawlana Bhashani Science and Technology University 2" Year 2"4 Semester B.Sc. (Engg,) Final Examination, 2018 = Title: Algorithm Design and Analy ‘Course Code: CSE-2201 3 hours, es 7 _ amie ‘Total marks: 70 [Answer any seven questions) yy Define algorithm. What are the eriteria ofa program to be considered as algorithm? 3 ° a) b) 9 a) ») ° ») a) » ° ‘What do you mean by recursive algorithm? Show that the solution of T(n)=T ([n/2)+1 4 is 0 (logn) ‘Write down the algorithm to delete an item from the binary search tree. {Let A and B be two nxn matrices. The product matrix C=A*B is also an n*n matrix. Given 4 1 4) ond pf © faecal Perform the matrix multiplication by Strassen’s Matrix Multiplication Algorithm. Matrix Multiplication Algorithm. It is possible to multiply 3*3 or 4°4 by Strassen Matrix Multiplication? How? Suppose you are given a Main text “abebdacbe” and Pattern is “abe” By using KMP algorithm 3 find the pattem in the given text. ‘An Ackermann’s function A(m,n) is defined as follows: 3 n+d ifm=0 A(m,n) = 9 A(mn — 1,1) ifm>Oandn=0 A(m —1,A(m,n—1)) itm >Oand n>0, Demonstrate how A(2,3)’s computation results in different steps. ‘When backtracking solutions are feasible for problem solving? Give an example. Determine an Longest Common Subsequence(LCS) of X=( ATCTGAT) and Y=( TGCA TA). Write an algorithm for Tower of Hannoi. Analyze the algorithm when no. of Disk=5. Consider the following instance of knapsack problem where 15,(P1,P24P3-7)=(10,5,15,7,8,15,3) and (W,W2,W5,..W9)=(2,3,6,7.2,4,1).Now calculate i. All feasible solution ii, Solution using greedy algorithm How do you define greedy choice property? Prove that 0/1 knapsack problem can not be 3 solved using greedy method. Distinguish between dynamic programming and divide and conquer approach. In which situation dynamic programming is preferred over divide-and-conquer approach? Explain with examples, 3 Let N be the number of queens are to be placed on an N*N chessboard so that no two attacks 3 that is no two queens are on the same row, column and diagonal Write an algorithm to solve the n-queens problem Draw the portion of solution space generated by N-queens problem for the number of queen 6. 4 A Two popular graph search algorithm are Breadth First Search and Depth Search Algorithm. 3 Write down the key differences between these two algorithm and other applications of these two algorithms. Apply DFS forthe following figure. 6. a) Write down the algorithm for greedy job scheduling. There are five Jobs with Wg z #3 . deadlines and profits are given. £o4 2 = [pia aP dj a ae et - 19 aa —_ a tp —_[s E 15 Find the maximum profit sequences of the above jobs with deadlines. b) Consider @ data file with 35000 characters. The characters in the file occur with the 4 Sequences given by 5 hook Frequency (in thousand) tte Generate the variable length code word using Huffman code algorithm. 7. a) Consider the following graph: 3 Compute the minimum spanning tree for the above mentioned graph using Prim’s algorithm. b) What is negative weight cycle? Apply Dijkastra’s algorithm to find the shortest path from the 5 source $ to all other vertices in the following graph. Also describe the limitations of Dijkstra’s algorithm. How can you overcome the shortcoming of Dijkstra’s algorithm? 8. a) Byusing Bellman-Ford Algorithm find the All-pairs shortest path forthe following figure. 4 "wn an algorithm to find a C ‘and test it using suitable data, t G be a graph m be a positive inte ‘way that no two adjacent nodes have What is graph coloring? Writ raph coloring algorithm for the following figure. ) A traveling salesman is getting ready fora big sales tour. following figure. Establish dynamic programming solutic Let's consider the directed graph of T ion of TSP. 0 4 uN ‘ONVEX HULL in a geometric plane using Quick Hull ‘the magic square having matrix 6%6 also write down thé sequence of steps, "get. Write an algorithm to color the graph G in such a the same color yet only m color is used, eth graph coloring algorithm using backtrack technique, Apply 14 22 0 9 10 B 8 ° 9 12 0 9 >) Determine an Longest Common Subsequence(LCS) of X=(A, Y=B.C.D,A.BA). Department of Computer Science ai Mawlana Bhashani Scie ind Engineering 2" year 2" semester B. nee and Technology University Se, (Engg.) Final Examination-2019 gerithen Design and Analysis Course Code: CSE-2201 Time: 3 hours (Answer any Seven from the following questions) Prgite algorithm. What are the advantages and disadvantages of Asymptotic Analysis? 3 ‘What does dfv) represent atthe end of the exceuton of Algorithm I, ite soraher applied 4 fon an unweighted directed acyclic graph (DAG) G with a source s? What the runtime complexity isin terms of IV I and FE Tof Algorithm 1? Algorithm 1 Compute a topological sorting of G for each vertex v in V[G] dlvi=0 for each u taken in topologically sorted order for each v in adj(u) if dfv]

You might also like