Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment
|
|
- Britney Martin
- 5 years ago
- Views:
Transcription
1 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 * b)f(n) = 6n + 10 * 20 c) f(n) = 69n 2 + n 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 n e) f(n) = 3*2 n + 58n c) 7n3 + n 2 = Ω(n 2 ) d) 7n + 3 = Ω(1) 8. Prove if f(n) = a m n m + a m-1 n m 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
2 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
3 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) + n 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 < α < 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
4 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 with 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 Si Fi 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
5 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 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 How divide and conquer differ from dynamic programming? V-CE-DAA-Assignment 5
6 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
7 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 A B C D E 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 A B C D V-CE-DAA-Assignment 7
8 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 Weight String Matching: Profit 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 Si Fi How fractional knapsack problem differ from binary knapsack problem? V-CE-DAA-Assignment 8
L.J. Institute of Engineering & Technology Semester: VIII (2016)
Subject Name: Design & Analysis of Algorithm Subject Code:1810 Faculties: Mitesh Thakkar Sr. UNIT-1 Basics of Algorithms and Mathematics No 1 What is an algorithm? What do you mean by correct algorithm?
More informationDepartment of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I
MCA 312: Design and Analysis of Algorithms [Part I : Medium Answer Type Questions] UNIT I 1) What is an Algorithm? What is the need to study Algorithms? 2) Define: a) Time Efficiency b) Space Efficiency
More informationCLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION
CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION 1. What is performance measurement? 2. What is an algorithm? 3. How the algorithm is good? 4. What are the
More informationDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Module 1 OBJECTIVE: Algorithms play the central role in both the science and the practice of computing. There are compelling reasons to study algorithms.
More information5105 BHARATHIDASAN ENGINEERING COLLEGE
CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS II CSE/IT /IV SEMESTER UNIT I PART A 1. Design an algorithm to compute the area and circumference of a circle?(dec 2016) 2. Define recurrence relation? (Dec 2016)
More informationEND-TERM EXAMINATION
(Please Write your Exam Roll No. immediately) Exam. Roll No... END-TERM EXAMINATION Paper Code : MCA-205 DECEMBER 2006 Subject: Design and analysis of algorithm Time: 3 Hours Maximum Marks: 60 Note: Attempt
More informationD.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1.
D.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1. DESIGN AND ANALYSIS OF ALGORITHM UNIT- I SECTION-A 2 MARKS 1. Define an algorithm? 2. Specify the criteria of algorithm? 3. What is Computational Procedure?
More informationCS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014
CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014 Study: Chapter 4 Analysis of Algorithms, Recursive Algorithms, and Recurrence Equations 1. Prove the
More informationR13 SET - 1. ''' '' ''' ' blog: anilkumarprathipati.wordpress.com. Code No: RT32054
R13 SET - 1 III B. Tech II Semester Regular Examinations, April - 2016 1 a) Distinguish between Algorithm and Psuedocode. [3M] b) Describe the Algorithm Analysis of Binary Search. [4M] c) State the Job
More informationContents. 1 Introduction. 2 Searching and Traversal Techniques. Preface... (vii) Acknowledgements... (ix)
Contents Preface... (vii) Acknowledgements... (ix) 1 Introduction 1.1 Algorithm 1 1.2 Life Cycle of Design and Analysis of Algorithm 2 1.3 Pseudo-Code for Expressing Algorithms 5 1.4 Recursive Algorithms
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Course Name : DESIGN AND ANALYSIS OF ALGORITHMS Course Code : AIT001 Class
More informationCS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I
CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I PART A(2MARKS) 1. What is an algorithm? 2. What is meant by open hashing? 3. Define Ω-notation 4.Define order of an algorithm. 5. Define O-notation
More information15CS43: DESIGN AND ANALYSIS OF ALGORITHMS
15CS43: DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK MODULE1 1. What is an algorithm? Write step by step procedure to write an algorithm. 2. What are the properties of an algorithm? Explain with an
More informationPSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V
PSD1A DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V UNIT I -- Introduction -- Definition of Algorithm -- Pseudocode conventions -- Recursive algorithms -- Time and space complexity -- Big- o notation --
More information2. (a) Explain when the Quick sort is preferred to merge sort and vice-versa.
Code No: RR210504 Set No. 1 1. (a) Order the following functions according to their order of growth (from the lowest to the highest). (n-2)!, 5 log (n+100) 10,2 2n, 0.001n 4 +3n 3 +1, ln 2 n, n 1/3, 3
More informationCSci 231 Final Review
CSci 231 Final Review Here is a list of topics for the final. Generally you are responsible for anything discussed in class (except topics that appear italicized), and anything appearing on the homeworks.
More informationModel Answer. Section A Q.1 - (20 1=10) B.Tech. (Fifth Semester) Examination Analysis and Design of Algorithm (IT3105N) (Information Technology)
B.Tech. (Fifth Semester) Examination 2013 Analysis and Design of Algorithm (IT3105N) (Information Technology) Model Answer. Section A Q.1 - (20 1=10) 1. Merge Sort uses approach to algorithm design. Ans:
More informationUNIT 1 BASICS OF AN ALGORITHM
UNIT 1 BASICS OF AN ALGORITHM Basics of an Algorithm Structure Page Nos. 1.0 Introduction 5 1.1 Objectives 6 1.2. Analysis and Complexity of Algorithms 6 1.3 Basic Technique for Design of Efficient Algorithms
More information( ) + n. ( ) = n "1) + n. ( ) = T n 2. ( ) = 2T n 2. ( ) = T( n 2 ) +1
CSE 0 Name Test Summer 00 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose you are sorting millions of keys that consist of three decimal
More informationCS583 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
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 Course Info course webpage: - from the syllabus on http://cs.gmu.edu/
More informationLecture 3. Brute Force
Lecture 3 Brute Force 1 Lecture Contents 1. Selection Sort and Bubble Sort 2. Sequential Search and Brute-Force String Matching 3. Closest-Pair and Convex-Hull Problems by Brute Force 4. Exhaustive Search
More informationIV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation
IV/IV B.Tech (Regular) DEGREE EXAMINATION Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation Maximum: 60 Marks 1. Write briefly about the following 1*12= 12 Marks a) Give the characteristics
More informationMidterm solutions. n f 3 (n) = 3
Introduction to Computer Science 1, SE361 DGIST April 20, 2016 Professors Min-Soo Kim and Taesup Moon Midterm solutions Midterm solutions The midterm is a 1.5 hour exam (4:30pm 6:00pm). This is a closed
More informationDEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: CS6402- Design & Analysis of Algorithm Year/Sem : II/IV UNIT-I INTRODUCTION
Chendu College of Engineering & Technology (Approved by AICTE, New Delhi and Affiliated to Anna University) Zamin Endathur, Madurantakam, Kancheepuram District 603311 +91-44-27540091/92 www.ccet.org.in
More informationCSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms. Lecturer: Shi Li
CSE 431/531: Algorithm Analysis and Design (Spring 2018) Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast
More informationDesign and Analysis of Algorithms
CSE 101, Winter 018 D/Q Greed SP s DP LP, Flow B&B, Backtrack Metaheuristics P, NP Design and Analysis of Algorithms Lecture 8: Greed Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Optimization
More informationYour favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY
Course Code : BCS-042 Course Title : Introduction to Algorithm Design Assignment Number : BCA(IV)-042/Assign/14-15 Maximum Marks : 80 Weightage : 25% Last Date of Submission : 15th October, 2014 (For July
More informationGreedy algorithms is another useful way for solving optimization problems.
Greedy Algorithms Greedy algorithms is another useful way for solving optimization problems. Optimization Problems For the given input, we are seeking solutions that must satisfy certain conditions. These
More informationCSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014
CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis Aaron Bauer Winter 2014 Previously, on CSE 373 We want to analyze algorithms for efficiency (in time and space) And do so generally
More informationUNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD
UNIT 3 Greedy Method GENERAL METHOD Greedy is the most straight forward design technique. Most of the problems have n inputs and require us to obtain a subset that satisfies some constraints. Any subset
More informationLecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions
U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front
More informationGreedy 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}.
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationIntroduction to Algorithms I
Summer School on Algorithms and Optimization Organized by: ACM Unit, ISI and IEEE CEDA. Tutorial II Date: 05.07.017 Introduction to Algorithms I (Q1) A binary tree is a rooted tree in which each node has
More informationCSE 431/531: Analysis of Algorithms. Greedy Algorithms. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo
CSE 431/531: Analysis of Algorithms Greedy Algorithms Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Main Goal of Algorithm Design Design fast algorithms to solve
More informationDESIGN AND ANALYSIS OF ALGORITHMS
QUESTION BANK DESIGN AND ANALYSIS OF ALGORITHMS UNIT1: INTRODUCTION OBJECTIVE: Algorithms play the central role in both the science and the practice of computing. There are compelling reasons to study
More informationESO207A: Data Structures and Algorithms End-semester exam
ESO207A: Data Structures and Algorithms End-semester exam Max marks: 120 Time: 180 mins. 17-July-2017 1. Answer all 7 questions. Questions 1 to 3 are from module 3 and questions 4 to 7 are from module
More informationAlgorithm Design Techniques part I
Algorithm Design Techniques part I Divide-and-Conquer. Dynamic Programming DSA - lecture 8 - T.U.Cluj-Napoca - M. Joldos 1 Some Algorithm Design Techniques Top-Down Algorithms: Divide-and-Conquer Bottom-Up
More informationReview for Midterm Exam
Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms
More informationAlgorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48
Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem
More information1. For the sieve technique we solve the problem, recursively mathematically precisely accurately 2. We do sorting to, keep elements in random positions keep the algorithm run in linear order keep the algorithm
More informationNotes 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.
COS 521 Fall 2009 Notes on Minimum Spanning Trees 1. The Generic Greedy Algorithm The generic greedy algorithm finds a minimum spanning tree (MST) by an edge-coloring process. Initially all edges are uncolored.
More informationAnany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &
Introduction to TllG DCSISFI & mmmmm Analysis of Algorithms 3RD EDITION Anany Levitin Villa nova University International Edition contributions by Soumen Mukherjee RCC Institute of Information Technology
More informationn 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)
CSE 0 Name Test Fall 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to find the maximum of the n elements of an integer array is in: A.
More informationCSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016
CSCE 321/3201 Analysis and Design of Algorithms Prof. Amr Goneid Fall 2016 CSCE 321/3201 Analysis and Design of Algorithms Prof. Amr Goneid Course Resources Instructor: Prof. Amr Goneid E-mail: goneid@aucegypt.edu
More informationTopic Analysis PART-A
Govt. of Karnataka, Department of Technical Education Diploma in Information Science & Engineering Third Semester Subject: ANALYSIS AND DESIGN OF ALGORITHM Contact Hrs / week: Total hrs: 64 Topic Analysis
More informationCS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK
CS 6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK Page 1 UNIT I INTRODUCTION 2 marks 1. Why is the need of studying algorithms? From a practical standpoint, a standard set of algorithms from different
More information6. Algorithm Design Techniques
6. Algorithm Design Techniques 6. Algorithm Design Techniques 6.1 Greedy algorithms 6.2 Divide and conquer 6.3 Dynamic Programming 6.4 Randomized Algorithms 6.5 Backtracking Algorithms Malek Mouhoub, CS340
More informationlooking ahead to see the optimum
! Make choice based on immediate rewards rather than looking ahead to see the optimum! In many cases this is effective as the look ahead variation can require exponential time as the number of possible
More informationFINAL EXAM SOLUTIONS
COMP/MATH 3804 Design and Analysis of Algorithms I Fall 2015 FINAL EXAM SOLUTIONS Question 1 (12%). Modify Euclid s algorithm as follows. function Newclid(a,b) if a
More information1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1
Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution
More informationChapter 3 Dynamic programming
Chapter 3 Dynamic programming 1 Dynamic programming also solve a problem by combining the solutions to subproblems. But dynamic programming considers the situation that some subproblems will be called
More informationTheorem 2.9: nearest addition algorithm
There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used
More informationData Structures and Algorithms
Data Structures and Algorithms About the course (objectives, outline, recommended reading) Problem solving Notions of Algorithmics (growth of functions, efficiency, programming model, example analysis)
More informationPlotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1
CS241 - week 1 review Special classes of algorithms: logarithmic: O(log n) linear: O(n) quadratic: O(n 2 ) polynomial: O(n k ), k 1 exponential: O(a n ), a > 1 Classifying algorithms is generally done
More informationIntroduction to Data Structure
Introduction to Data Structure CONTENTS 1.1 Basic Terminology 1. Elementary data structure organization 2. Classification of data structure 1.2 Operations on data structures 1.3 Different Approaches to
More information15.4 Longest common subsequence
15.4 Longest common subsequence Biological applications often need to compare the DNA of two (or more) different organisms A strand of DNA consists of a string of molecules called bases, where the possible
More information( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο
CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally
More informationPROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationCS-6402 DESIGN AND ANALYSIS OF ALGORITHMS
CS-6402 DESIGN AND ANALYSIS OF ALGORITHMS 2 marks UNIT-I 1. Define Algorithm. An algorithm is a sequence of unambiguous instructions for solving a problem in a finite amount of time. 2.Write a short note
More informationlogn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)
CSE 0 Test Your name as it appears on your UTA ID Card Fall 0 Multiple Choice:. Write the letter of your answer on the line ) to the LEFT of each problem.. CIRCLED ANSWERS DO NOT COUNT.. points each. The
More informationR10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May
www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the
More informationn 2 ( ) ( ) + n is in Θ n logn
CSE Test Spring Name Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply an m n matrix and a n p matrix is in: A. Θ( n) B. Θ( max(
More informationTOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5
Course Title: Analysis & Design of Algorithm Course Level: UG Course Code: CSE303 Credit Units: 5 L T P/ S SW/F W TOTAL CREDIT UNITS 3 1 2-5 Course Objectives: The designing of algorithm is an important
More informationIntroduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.
Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Practice Final Practice Final Do not open this exam booklet until
More informationDATA STRUCTURES AND ALGORITHMS
DATA STRUCTURES AND ALGORITHMS For COMPUTER SCIENCE DATA STRUCTURES &. ALGORITHMS SYLLABUS Programming and Data Structures: Programming in C. Recursion. Arrays, stacks, queues, linked lists, trees, binary
More informationAlgorithms and Data Structures (INF1) Lecture 15/15 Hua Lu
Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu Department of Computer Science Aalborg University Fall 2007 This Lecture Minimum spanning trees Definitions Kruskal s algorithm Prim s algorithm
More informationLecture Summary CSC 263H. August 5, 2016
Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.
More informationUnit-5 Dynamic Programming 2016
5 Dynamic programming Overview, Applications - shortest path in graph, matrix multiplication, travelling salesman problem, Fibonacci Series. 20% 12 Origin: Richard Bellman, 1957 Programming referred to
More informationData Structures and Algorithms. Part 2
1 Data Structures and Algorithms Part 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples displayed
More information( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1
CSE 0 Name Test Summer 006 Last Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n x n matrices is: A. "( n) B. "( nlogn) # C.
More informationData Structures and Algorithms Chapter 2
1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples
More informationOptimization II: Dynamic Programming
Chapter 12 Optimization II: Dynamic Programming In the last chapter, we saw that greedy algorithms are efficient solutions to certain optimization problems. However, there are optimization problems for
More informationVirtual University of Pakistan
Virtual University of Pakistan Department of Computer Science Course Outline Course Instructor Dr. Sohail Aslam E mail Course Code Course Title Credit Hours 3 Prerequisites Objectives Learning Outcomes
More information( ) n 3. n 2 ( ) D. Ο
CSE 0 Name Test Summer 0 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to multiply two n n matrices is: A. Θ( n) B. Θ( max( m,n, p) ) C.
More informationPractice Problems for the Final
ECE-250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each
More informationWeek 11: Minimum Spanning trees
Week 11: Minimum Spanning trees Agenda: Minimum Spanning Trees Prim s Algorithm Reading: Textbook : 61-7 1 Week 11: Minimum Spanning trees Minimum spanning tree (MST) problem: Input: edge-weighted (simple,
More informationDynamic Programming Homework Problems
CS 1510 Dynamic Programming Homework Problems 1. Consider the recurrence relation T(0) = T(1) = 2 and for n > 1 n 1 T(n) = T(i)T(i 1) i=1 We consider the problem of computing T(n) from n. (a) Show that
More informationDr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions
Dr. Amotz Bar-Noy s Compendium of Algorithms Problems Problems, Hints, and Solutions Chapter 1 Searching and Sorting Problems 1 1.1 Array with One Missing 1.1.1 Problem Let A = A[1],..., A[n] be an array
More information1. 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.
CSE 5311 Test 1 - Closed Book Spring 004 Name Student ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. To reduce the probability of having any collisions to < 0.5 when
More informationMultiple Choice Question. Unit-1 Introduction
Multiple Choice Question Unit-1 Introduction 1. In analysis of algorithm, approximate relationship between the size of the job and the amount of work required to do is expressed by using (a) Central tendency
More informationCS6402 Design and Analysis of Algorithm. 2 Marks Question & Answer UNIT I INTRODUCTION
CS6402 Design and Analysis of Algorithm 2 Marks Question & Answer UNIT I INTRODUCTION 1. What is performance measurement? Performance measurement is concerned with obtaining the space and the time requirements
More informationAlgorithm Analysis. Jordi Cortadella and Jordi Petit Department of Computer Science
Algorithm Analysis Jordi Cortadella and Jordi Petit Department of Computer Science What do we expect from an algorithm? Correct Easy to understand Easy to implement Efficient: Every algorithm requires
More informationCOE428 Lecture Notes Week 1 (Week of January 9, 2017)
COE428 Lecture Notes: Week 1 1 of 10 COE428 Lecture Notes Week 1 (Week of January 9, 2017) Table of Contents COE428 Lecture Notes Week 1 (Week of January 9, 2017)...1 Announcements...1 Topics...1 Informal
More informationMultiple-choice (35 pt.)
CS 161 Practice Midterm I Summer 2018 Released: 7/21/18 Multiple-choice (35 pt.) 1. (2 pt.) Which of the following asymptotic bounds describe the function f(n) = n 3? The bounds do not necessarily need
More informationAlgorithms and Data Structures
Algorithm Analysis Page 1 - Algorithm Analysis Dr. Fall 2008 Algorithm Analysis Page 2 Outline Textbook Overview Analysis of Algorithm Pseudo-Code and Primitive Operations Growth Rate and Big-Oh Notation
More informationFramework for Design of Dynamic Programming Algorithms
CSE 441T/541T Advanced Algorithms September 22, 2010 Framework for Design of Dynamic Programming Algorithms Dynamic programming algorithms for combinatorial optimization generalize the strategy we studied
More informationHere is a recursive algorithm that solves this problem, given a pointer to the root of T : MaxWtSubtree [r]
CSE 101 Final Exam Topics: Order, Recurrence Relations, Analyzing Programs, Divide-and-Conquer, Back-tracking, Dynamic Programming, Greedy Algorithms and Correctness Proofs, Data Structures (Heap, Binary
More informationCAD Algorithms. Categorizing Algorithms
CAD Algorithms Categorizing Algorithms Mohammad Tehranipoor ECE Department 2 September 2008 1 Categorizing Algorithms Greedy Algorithms Prim s Algorithm (Minimum Spanning Tree) A subgraph that is a tree
More informationCS521 \ Notes for the Final Exam
CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )
More informationGreedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationCSE 332, Spring 2010, Midterm Examination 30 April 2010
CSE 332, Spring 2010, Midterm Examination 30 April 2010 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note. You may use a calculator for basic arithmetic only.
More informationAlgorithms and Theory of Computation. Lecture 2: Big-O Notation Graph Algorithms
Algorithms and Theory of Computation Lecture 2: Big-O Notation Graph Algorithms Xiaohui Bei MAS 714 August 15, 2017 Nanyang Technological University MAS 714 August 15, 2017 1 / 22 O, Ω, and Θ Let T, f
More information9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?
1 1 Name Test 1 - Closed Book Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each 1. During which operation on a leftist heap may subtree swaps be needed? A. DECREASE-KEY
More informationO(n): printing a list of n items to the screen, looking at each item once.
UNIT IV Sorting: O notation efficiency of sorting bubble sort quick sort selection sort heap sort insertion sort shell sort merge sort radix sort. O NOTATION BIG OH (O) NOTATION Big oh : the function f(n)=o(g(n))
More informationCOMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018
COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018 Name: ID: Answer the questions directly on the exam pages. Show all your work for each question. More detail including comments
More informationGreedy Algorithms CHAPTER 16
CHAPTER 16 Greedy Algorithms In dynamic programming, the optimal solution is described in a recursive manner, and then is computed ``bottom up''. Dynamic programming is a powerful technique, but it often
More informationCSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD
Recap. Growth rates: Arrange the following functions in ascending order of growth rate: n 2 log n n log n 2 log n n/ log n n n Introduction Algorithm: A step-by-step way of solving a problem. Design of
More informationChapter 6. Dynamic Programming
Chapter 6 Dynamic Programming CS 573: Algorithms, Fall 203 September 2, 203 6. Maximum Weighted Independent Set in Trees 6..0. Maximum Weight Independent Set Problem Input Graph G = (V, E) and weights
More information( D. Θ n. ( ) f n ( ) D. Ο%
CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j
More informationName: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.
1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G. A shortest s-t path is a path from vertex to vertex, whose sum of edge weights is minimized. (b) Give the pseudocode
More information