DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-III. SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks)
|
|
- Brian Day
- 6 years ago
- Views:
Transcription
1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-III SUB CODE: CS2251 DEPT: CSE SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks) 1. Write any four examples for Brute-force approach. (AUC DEC 2005) Brute force is a straightforward approach to solve a problem based on the problem s statement and definitions of the concepts involved. It is considered as one of the easiest approach to apply and is useful for solving small size instances of a problem. Example 1: Computing an (a > 0, n a nonnegative integer) based on the definition of exponentiation a n = a* a* a*. * a The brute force algorithm requires n-1 multiplications. The recursive algorithm for the same problem, based on the observation that an = an/2 * an/2 requires Θ(log(n)) operations. Example 2: Computing n! Based on the definition n! = 1*2*3* *n The algorithm requires Θ (n) operations. Example 3: Multiply two matrices. Example 4. Searching for a key of a given value in a list. 2. What is meant by optimal solution? (AUC JUN 2007, DEC 2013) Optimal solution is best possible feasible solution with less time complexity and solves all instances of the problem. 3. Define Multistage Graphs. (AUC MAY, DEC 2010) A multi-stage graph is a directed graph G = <V, E >, in which nodes are partitioned into K>=2 disjoint sets, V i, 1<= i< = K. 4. Define Optimal Binary Search Tree. (AUC MAY/JUN 2010) A binary search tree is one of the most important data structures in computer science. Its principle application is dictionary, a set of elements with the operations of searching, insertion and deletion. If probabilities of searching for elements of a set are known ( from accumulated data about past searches), the average number of comparisons in a search will have smallest possible value in an optimal binary search tree. 5. What is a multistage path? (AUC JUN 2010) M.AARTHI Mahalakshmi Engineering College Page 1
2 A multi-stage graph is a directed graph G = < V, E >, in which nodes are partitioned into K>=2 disjoint sets, V i, 1<= I <= K 6. State the principle behind dynamic programming. (AUC DEC 2010) Dynamic programming is an algorithm design method that can be used when the solution to a problem can be viewed as a result of a sequence of decisions. Dynamic programming is a general algorithm design technique for solving problems defined by recurrences with overlapping sub problems. 7. State the principle of optimality. (AUC DEC 2010,JUN 2012) Optimal solution is best possible feasible solution with less time complexity and solves all instances of the problem. 8. Compare divide and conquer with dynamic programming and dynamic programming with greedy algorithm. (AUC DEC 2010) Dynamic programming is a general algorithm design technique for solving problems defined by recurrence with overlapping sub problems. Main idea: Set up a recurrence relating a solution to a larger instance to solutions of some smaller instances. Solve smaller instances once Record solutions in a table Extract solution to the initial instance from the table. The causes of inefficiency in divide and conquer After division: Smaller instances are unrelated, e.g., merge sort Smaller instances are related, e.g., Fibonacci Repeatedly solve common instances. 9. Write the difference between Greedy Method and Dynamic Programming.(AUC MAY 2011, MAY 2012, DEC 2012) The essential difference between the greedy technique and dynamic programming is that in the greedy method only one decision sequence is ever generated. In dynamic programming, many decision sequences may be generated. However, sequences containing sub optimal sequences cannot be optimal ( if the principle of optimality holds) and so will not be generated. 10. Write an algorithm to find the shortest path between all pair of nodes. (AUC MAY 2011) M.AARTHI Mahalakshmi Engineering College Page 2
3 Algorithm: void AllPaths ( float cost [] [SIZE], float A[] [ SIZE], int n) // cost[ 1:n ] [ 1:n ] is the cost adjacency matrix of // a graph with n vertices; A[i] [j] is the cost // of a shortest path from vertex I to vertex j. // cost[i] [i] = 0.0, for 1<=i<=n. { for(int i=1;i<=n;i++) for(int j=1;j<=n; j++) A[i] [j] = cost[i] [j] ; // Copy cost into A for( i=1; i<=n; i++) for(j=1; j<=n;j++) A[i][j] = min(a[i] [j], A[i] [k] + A[k] [j]); } 11. What is travelling salesman problem? (AUC DEC 2011) It is a permutation problem. It is also untraceable. We try to apply dynamic programming approach to the problem. For example, suppose a salesman is planning a sales trip that includes 20 cities. Each city is connected to some of the other cities by road. To minimize travel time, we want to determine a shortest route that starts at the salesman s home city, visits each of the cities once, and ends up at the home city. This problem of determining a shortest route is called Travelling Salesperson Problem. 12. What do you meant by multi stage graphs? (AUC DEC 2011) A multi- stage graph is a directed G = < V,E>, in which nodes are partitioned into K>=2 disjoint sets, V i, 1<=I <= K. 13. What is 0/1 knapsack problem? ( AUC DEC 2012, DEC 2013) In 0/1 knapsack, the value of xi s are restricted to have either 0 or 1, using KNAP (l, j, y) is used to represent the problem. maximize p i x i Subject to w i x i <= y x i = 0 or 1 l <= i <= j, where y is the capacity of knapsack or bag. M.AARTHI Mahalakshmi Engineering College Page 3
4 14. What is the time complexity of knapsack problem? The knapsack problem is a problem in combinatorial optimization: Given a set of items, each with a mass and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. 16. What is the time complexity in travelling salesman problem? Refer question No:2 Part-B 15. Give the use of Dijkstras and Floyd s algorithms. If we use Dijkstras shortest source algorithm n times, once with each of the n vertices as the source vertex, using greedy approach. Time complexity is: Each node requires O(n 2 ), so total time for n nodes is O(n 3 ). Restriction works only when no edge has a cost < What is the cost function of OBST? The expected cost of the left sub tree is given by, Cost (l) = p(i) * level(a i ) + q(i) * (level(e i )-1) I<=i<=k 0<=i<=k 17. Write pseudocode of forward and backward approach in multi-stage graph? void FGraph(graph G, int k, int n,int p[]) { float cost [MAXSIZE]; int d [MAXSIZE],r; cost[n] = 0.0; for(int i=j; j>=1;j--) { let r be a vertex such that <j,r> is an edge of G and c[j][r] + cost[r] is minimum; Cost[j] = c[j][r] + cost[r]; d[j] = r; } //Find minimum cost path p[1] = 1; p[k] = n; for(j=2;j<=k;j++) p[j] = d[p[j-1]]; M.AARTHI Mahalakshmi Engineering College Page 4
5 } 18. How will you construct an optimal binary search tree? 1. To obtain an OBST using Dynamic Programming, we need to take a sequence of decisions. 2. Observe the principle of optimality holds. 3. The construction of tree is as follows: a). First decision is which of a i s should be assigned as root node. b). If we choose a k as root, then the internal nodes a 1,a 2,a 3,---,a k-1 and the external nodes for the class E 0,E 1,---E k-1 will lie in the left sub tree, l of the root. c). The remaining nodes will be in the right sub tree R. 19. What are the variants of knapsack problem? To maximize the total profit earned by filling the bag appropriately. In other words formally stated: maximize p i x i 1<=i<=n 1<=i<=k 0<=x i <=1 Subject to w i x i <=m 1<=i<=n 20. Define Dynamic programming. Dynamic programming is an algorithm design method that can be used when the solution to a problem can be viewed as a result of a sequence of decisions. Dynamic programming is a general algorithm design techniques for solving problems defined by recurrences with overlapping sub problems. 21. What is the advantage of dynamic programming? Dynamic programming is a method for solving complex problems by breaking them down into simpler subproblems. It is applicable to problems exhibiting the properties of overlapping subproblems and optimal substructure. When applicable, the method takes far less time than naive methods that don't take advantage of the sub problem overlap (like depth-first search). M.AARTHI Mahalakshmi Engineering College Page 5
6 PART-B (16 Marks) 1. Write down and explain the algorithm to solve all pairs shortest paths problem. (16) (AUC MAY 2010/ JUN 2012) Dynamic programming is an algorithm design method that can be used when the solution to a problem can be viewed as a result of a sequence of decisions. Dynamic programming is a general algorithm design technique for solving problems defined by recurrences with overlapping sub problems. M.AARTHI Mahalakshmi Engineering College Page 6
7 M.AARTHI Mahalakshmi Engineering College Page 7
8 Example: Find the shortest path between any pair of vertices for the following graph. M.AARTHI Mahalakshmi Engineering College Page 8
9 2. Explain how dynamic programming is applied to solve travelling salesperson problem. (16) Explain how travelling salesperson problem could be solved using dynamic programming method. Explain with sample graph. (8) M.AARTHI Mahalakshmi Engineering College Page 9
10 Explain the Travelling salesman problem and apply dynamic programming to solve it.(16) (AUC MAY 2010/ JUN 2012/ JUN 2010) It is a permutation problem. It is also untraceable. We try to apply dynamic programming approach to the problem. For example, suppose a salesman is planning a sales trip that includes 20 cities. Each city is connected to some of the other cities by a road. To maximize travel time, we want to determine a shortest route that starts at the salesman s home city, visits each of the cities once, and ends up at the home city. This problem of determining a shortest route is called Travelling salesperson problem. DYNAMIC PROGRAMMING APPROACH M.AARTHI Mahalakshmi Engineering College Page 10
11 M.AARTHI Mahalakshmi Engineering College Page 11
12 M.AARTHI Mahalakshmi Engineering College Page 12
13 M.AARTHI Mahalakshmi Engineering College Page 13
14 3. What is Dynamic programming? Apply this technique to find all pairs shortest path in a graph. (16) (AUC MAY2010) Write and explain the algorithm to compute the all pairs source shortest path using dynamic programming and prove that it is optimal. (8) (AUC DEC 2010) M.AARTHI Mahalakshmi Engineering College Page 14
15 M.AARTHI Mahalakshmi Engineering College Page 15
16 M.AARTHI Mahalakshmi Engineering College Page 16
17 4. For the following graph having four nodes represented by the matrix given below determine the all pairs source shortest path (8) (AUC DEC 2010) M.AARTHI Mahalakshmi Engineering College Page 17
18 SOLUTION M.AARTHI Mahalakshmi Engineering College Page 18
19 5. Write the algorithm to compute the 0/1 knapsack problem using dynamic programming and explain it. (8) (AUC DEC 2010) M.AARTHI Mahalakshmi Engineering College Page 19
20 Solve the following instance of the 0/1 knapsack problem given the knapsack capacity is W=5 (8) (AUC DEC 2010) Items Weight Value M.AARTHI Mahalakshmi Engineering College Page 20
21 M.AARTHI Mahalakshmi Engineering College Page 21
22 M.AARTHI Mahalakshmi Engineering College Page 22
23 M.AARTHI Mahalakshmi Engineering College Page 23
24 M.AARTHI Mahalakshmi Engineering College Page 24
25 M.AARTHI Mahalakshmi Engineering College Page 25
26 9. Use function OBST to compute w(i, j), r(i, j), and c(i, j), 0<=i<j<=4, for the identifier set ( ) ,,, a aaa = (cout, float, if, while) with p(1) = 1/20, p(2) = 1/5, p(3) = 1/10, p(4) = 1/20, q(0) = 1/5, q(1) = 1/10, q(2) = 1/5, q(3) = 1/20, and q(4) 1/20. Using the r(i, j) s, construct the optimal binary search tree.(16) (AUC MAY 2011) M.AARTHI Mahalakshmi Engineering College Page 26
27 Given: n = 4, (a1, a2, a3, a4) = {cout, float, if, while} p(1: 4) {,,, } q(0 : 4) {,,,, } Multiply p&q byfor convenience.the resultant is : p(1: 4) {1,4,2,1} q(0 : 4) {4,2,4,1,1} Solution : c(i,i) 0 w(i,i) q(i) 0 i n r(i,i) 0 0 i n( i, e) n 4 Initially, M.AARTHI Mahalakshmi Engineering College Page 27
28 r (3,4) = value of k that minimizes c(3,4) = 4 Compute w (I, i+2j, c(i, i+2) 0 I <3 M.AARTHI Mahalakshmi Engineering College Page 28
29 w (0,2) = p(2) + q(2) + w(0,1) =4+4+7 =15 c(0,2) = min { c(0,0) + c(1,2), c(0,1) + c(2,2)} + w(0,2) 0<k 2 k=1 (or) k=2 = min { 0 +10, 7+10} +15 =7 +15 =22 M.AARTHI Mahalakshmi Engineering College Page 29
30 10. Using dynamic approach programming, solve the following graph using the backward approach. (16) (AUC MAY2011) M.AARTHI Mahalakshmi Engineering College Page 30
31 11. Explain the multistage graph problem with an example. Analyze its time complexity. (8) (AUC DEC 2011) M.AARTHI Mahalakshmi Engineering College Page 31
32 12. Find an optimal solution to the knapsack instance n=7, m=15 (p1,p2,p3---p7) = (10,5,15,7,6,18,3) and (w1,w2,w3,----w7) (2,3,5,7,1,4,1) (AUCDEC 2011) Solution: (i) (ii) (iii) M.AARTHI Mahalakshmi Engineering College Page 32
33 13. Describe binary search tree with tree traversal patterns? Give suitable example with neat diagram for all three traversal of binary search tree. (8) (AUCDEC 2011) inorder (T-> right) } } 1. Pre order traversal The preorder traversal of a binary tree is performed as follows: M.AARTHI Mahalakshmi Engineering College Page 33
34 Recursive routine for preorder traversal 2. Post order traversal The post order traversal of a binary tree is performed as follows: 14. Explain how principle of optimality holds for the following problem does: 1. Knapsack 2.Shortest path 3.TSP 14. Discuss the algorithm for finding a minimum cost binary search trees.explain with suitable example.(or) Explain in detail about the construction of OBST.(AUC DEC 2012) Construction of Optimal Binary Search Tree (OBST) 1. To obtain an OBST using Dynamic Programming, we need to take a sequence of decisions. 2. Observe the principle of optimality holds. M.AARTHI Mahalakshmi Engineering College Page 34
35 3. The construction of tree is as follows: a). First decision is which of a i s should be assigned as root node. b). If we choose a k as root, then the internal nodes a 1,a 2,a 3,---,a k-1 and the external nodes for the class E 0,E 1,---E k-1 will lie in the left sub tree, l of the root. c). The remaining nodes will be in the right sub tree R. M.AARTHI Mahalakshmi Engineering College Page 35
36 M.AARTHI Mahalakshmi Engineering College Page 36
37 M.AARTHI Mahalakshmi Engineering College Page 37
38 M.AARTHI Mahalakshmi Engineering College Page 38
39 M.AARTHI Mahalakshmi Engineering College Page 39
40 M.AARTHI Mahalakshmi Engineering College Page 40
41 16. Solve 0/1 knapsack problem for the given n=3, (w1,w2.w3,w4)=(2,1,3,2) & (p1,p2,p3,p4)=(12,10,20,15) using DP With knapsack capacity m= Explain Multi-stage Graph Problem. Find the minimum cost path from source to destination for the given graph using both forward and backward approach. (AUC DEC 2011) Forward Approach: Figure: Five stage graph. M.AARTHI Mahalakshmi Engineering College Page 41
42 M.AARTHI Mahalakshmi Engineering College Page 42
43 M.AARTHI Mahalakshmi Engineering College Page 43
44 M.AARTHI Mahalakshmi Engineering College Page 44
45 M.AARTHI Mahalakshmi Engineering College Page 45
******** Chapter-4 Dynamic programming
repeat end SHORT - PATHS Overall run time of algorithm is O ((n+ E ) log n) Example: ******** Chapter-4 Dynamic programming 4.1 The General Method Dynamic Programming: is an algorithm design method that
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 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 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 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 informationAlgorithm classification
Types of Algorithms Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We ll talk about a classification scheme for algorithms This classification scheme
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 informationSankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment
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
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 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 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 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 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 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 informationIntroduction to Algorithms
Introduction to Algorithms Dynamic Programming Well known algorithm design techniques: Brute-Force (iterative) ti algorithms Divide-and-conquer algorithms Another strategy for designing algorithms is dynamic
More informationAlgorithms IV. Dynamic Programming. Guoqiang Li. School of Software, Shanghai Jiao Tong University
Algorithms IV Dynamic Programming Guoqiang Li School of Software, Shanghai Jiao Tong University Dynamic Programming Shortest Paths in Dags, Revisited Shortest Paths in Dags, Revisited The special distinguishing
More informationIN101: Algorithmic techniques Vladimir-Alexandru Paun ENSTA ParisTech
IN101: Algorithmic techniques Vladimir-Alexandru Paun ENSTA ParisTech License CC BY-NC-SA 2.0 http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Outline Previously on IN101 Python s anatomy Functions,
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 information1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18
CS 124 Quiz 2 Review 3/25/18 1 Format You will have 83 minutes to complete the exam. The exam may have true/false questions, multiple choice, example/counterexample problems, run-this-algorithm problems,
More informationL.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 information1 Non greedy algorithms (which we should have covered
1 Non greedy algorithms (which we should have covered earlier) 1.1 Floyd Warshall algorithm This algorithm solves the all-pairs shortest paths problem, which is a problem where we want to find the shortest
More informationCSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach
CSC 8301- Design and Analysis of Algorithms Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms Brute-Force Approach Brute force is a straightforward approach to solving a problem, usually
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 informationWe ve done. Now. Next
We ve done Fast Fourier Transform Polynomial Multiplication Now Introduction to the greedy method Activity selection problem How to prove that a greedy algorithm works Huffman coding Matroid theory Next
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 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 informationData Structures, Algorithms & Data Science Platforms
Indian Institute of Science Bangalore, India भ रत य व ज ञ न स स थ न ब गल र, भ रत Department of Computational and Data Sciences DS221 19 Sep 19 Oct, 2017 Data Structures, Algorithms & Data Science Platforms
More informationUniversity of the Western Cape Department of Computer Science
University of the Western Cape Department of Computer Science Algorithms and Complexity CSC212 Paper II Final Examination 13 November 2015 Time: 90 Minutes. Marks: 100. UWC number Surname, first name Mark
More informationGreedy Algorithms. Informal Definition A greedy algorithm makes its next step based only on the current state and simple calculations on the input.
Greedy Algorithms Informal Definition A greedy algorithm makes its next step based only on the current state and simple calculations on the input. easy to design not always correct challenge is to identify
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 informationChapter 9 Graph Algorithms
Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)
More information11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions
Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 15, 2015 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 6, 2016 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 6, 2016 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing up
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 informationHomework3: Dynamic Programming - Answers
Most Exercises are from your textbook: Homework3: Dynamic Programming - Answers 1. For the Rod Cutting problem (covered in lecture) modify the given top-down memoized algorithm (includes two procedures)
More informationn 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο
CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in:
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 informationComputer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: Dynamic Programming
Computer Science 385 Design and Analysis of Algorithms Siena College Spring 29 Topic Notes: Dynamic Programming We next consider dynamic programming, a technique for designing algorithms to solve problems
More information9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)
CSE 0 Name Test Spring 006 Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the
More informationComputer Sciences Department 1
1 Advanced Design and Analysis Techniques (15.1, 15.2, 15.3, 15.4 and 15.5) 3 Objectives Problem Formulation Examples The Basic Problem Principle of optimality Important techniques: dynamic programming
More informationAnalysis of Algorithms Prof. Karen Daniels
UMass Lowell Computer Science 91.503 Analysis of Algorithms Prof. Karen Daniels Spring, 2010 Lecture 2 Tuesday, 2/2/10 Design Patterns for Optimization Problems Greedy Algorithms Algorithmic Paradigm Context
More informationDESIGN AND ANALYSIS OF ALGORITHMS GREEDY METHOD
1 DESIGN AND ANALYSIS OF ALGORITHMS UNIT II Objectives GREEDY METHOD Explain and detail about greedy method Explain the concept of knapsack problem and solve the problems in knapsack Discuss the applications
More informationSolving NP-hard Problems on Special Instances
Solving NP-hard Problems on Special Instances Solve it in poly- time I can t You can assume the input is xxxxx No Problem, here is a poly-time algorithm 1 Solving NP-hard Problems on Special Instances
More informationCSC 8301 Design and Analysis of Algorithms: Exhaustive Search
CSC 8301 Design and Analysis of Algorithms: Exhaustive Search Professor Henry Carter Fall 2016 Recap Brute force is the use of iterative checking or solving a problem by its definition The straightforward
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 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 informationDynamic programming. Trivial problems are solved first More complex solutions are composed from the simpler solutions already computed
Dynamic programming Solves a complex problem by breaking it down into subproblems Each subproblem is broken down recursively until a trivial problem is reached Computation itself is not recursive: problems
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 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 informationTest 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1
CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each t. What is the value of k? k=0 A. k B. t C. t+ D. t+ +. Suppose that you have
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 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 informationMultiple Choice. Write your answer to the LEFT of each problem. 3 points each
CSE 0-00 Test Spring 0 Name Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the
More informationArtificial Intelligence
Artificial Intelligence Shortest Path Problem G. Guérard Department of Nouvelles Energies Ecole Supérieur d Ingénieurs Léonard de Vinci Lecture 3 GG A.I. 1/42 Outline 1 The Shortest Path Problem Introduction
More informationSlides for a Course on the Analysis and Design of Algorithms
Slides for a Course on the Analysis and Design of Algorithms Chapter 4: Dynamic Programming and Optimization Stephen J Hegner Department of Computing Science Umeå University Sweden hegner@csumuse http://wwwcsumuse/
More informationOverview of Data Structures, Algorithm Analysis
SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : Advanced Data structures and Algorithms (16CS5804) Year & Sem: M.Tech
More informationCS 440 Theory of Algorithms /
CS 440 Theory of Algorithms / CS 468 Algorithms in Bioinformaticsi Brute Force. Design and Analysis of Algorithms - Chapter 3 3-0 Brute Force A straightforward approach usually based on problem statement
More informationDynamic Programming II
Lecture 11 Dynamic Programming II 11.1 Overview In this lecture we continue our discussion of dynamic programming, focusing on using it for a variety of path-finding problems in graphs. Topics in this
More informationCS Algorithms and Complexity
CS 350 - Algorithms and Complexity Dynamic Programming Sean Anderson 2/20/18 Portland State University Table of contents 1. Homework 3 Solutions 2. Dynamic Programming 3. Problem of the Day 4. Application
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 informationDynamic Programming Homework Problems
CS 1510 Dynamic Programming Homework Problems 1. (2 points) 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
More informationCMSC 451: Dynamic Programming
CMSC 41: Dynamic Programming Slides By: Carl Kingsford Department of Computer Science University of Maryland, College Park Based on Sections 6.1&6.2 of Algorithm Design by Kleinberg & Tardos. Dynamic Programming
More information( ) 1 B. 1. Suppose f x
CSE Name Test Spring Last Digits of Student ID Multiple Choice. Write your answer to the LEFT of each problem. points each is a monotonically increasing function. Which of the following approximates the
More informationComputer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: Brute-Force Algorithms
Computer Science 385 Design and Analysis of Algorithms Siena College Spring 2019 Topic Notes: Brute-Force Algorithms Our first category of algorithms are called brute-force algorithms. Levitin defines
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 informationSo far... Finished looking at lower bounds and linear sorts.
So far... Finished looking at lower bounds and linear sorts. Next: Memoization -- Optimization problems - Dynamic programming A scheduling problem Matrix multiplication optimization Longest Common Subsequence
More informationDynamic Programming. December 15, CMPE 250 Dynamic Programming December 15, / 60
Dynamic Programming December 15, 2016 CMPE 250 Dynamic Programming December 15, 2016 1 / 60 Why Dynamic Programming Often recursive algorithms solve fairly difficult problems efficiently BUT in other cases
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 informationShortest path problems
Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths
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 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 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 informationCS 491 CAP Intermediate Dynamic Programming
CS 491 CAP Intermediate Dynamic Programming Victor Gao University of Illinois at Urbana-Champaign Oct 28, 2016 Linear DP Knapsack DP DP on a Grid Interval DP Division/Grouping DP Tree DP Set DP Outline
More informationAlgorithms ~ R-ES-O-N-A-N--C-E-I-A-U-9-U-st Algorithm Design Techniques.
Algorithms 8. Algorithm Design Techniques R K Shyamasundar This article continues with the exploration of common algorithm design techniques. In particular, we discuss balancing, greedy strategy, backtracking
More informationA 0 A 1... A i 1 A i,..., A min,..., A n 1 in their final positions the last n i elements After n 1 passes, the list is sorted.
CS6402 Design and Analysis of Algorithms _ Unit II 2.1 UNIT II BRUTE FORCE AND DIVIDE-AND-CONQUER 2.1 BRUTE FORCE Brute force is a straightforward approach to solving a problem, usually directly based
More informationData Structures and Algorithms Week 8
Data Structures and Algorithms Week 8 Dynamic programming Fibonacci numbers Optimization problems Matrix multiplication optimization Principles of dynamic programming Longest Common Subsequence Algorithm
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 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 information) $ f ( n) " %( g( n)
CSE 0 Name Test Spring 008 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to compute the sum of the n elements of an integer array is: # A.
More informationCMSC 451: Lecture 10 Dynamic Programming: Weighted Interval Scheduling Tuesday, Oct 3, 2017
CMSC 45 CMSC 45: Lecture Dynamic Programming: Weighted Interval Scheduling Tuesday, Oct, Reading: Section. in KT. Dynamic Programming: In this lecture we begin our coverage of an important algorithm design
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 informationExam Sample Questions CS3212: Algorithms and Data Structures
Exam Sample Questions CS31: Algorithms and Data Structures NOTE: the actual exam will contain around 0-5 questions. 1. Consider a LinkedList that has a get(int i) method to return the i-th element in the
More informationLecture 3, Review of Algorithms. What is Algorithm?
BINF 336, Introduction to Computational Biology Lecture 3, Review of Algorithms Young-Rae Cho Associate Professor Department of Computer Science Baylor University What is Algorithm? Definition A process
More informationCSCE 350: Chin-Tser Huang. University of South Carolina
CSCE 350: Data Structures and Algorithms Chin-Tser Huang huangct@cse.sc.edu University of South Carolina Announcement Homework 2 will be returned on Thursday; solution will be available on class website
More informationCSE 4/531 Solution 3
CSE 4/531 Solution 3 Edited by Le Fang November 7, 2017 Problem 1 M is a given n n matrix and we want to find a longest sequence S from elements of M such that the indexes of elements in M increase and
More informationSubsequence Definition. CS 461, Lecture 8. Today s Outline. Example. Assume given sequence X = x 1, x 2,..., x m. Jared Saia University of New Mexico
Subsequence Definition CS 461, Lecture 8 Jared Saia University of New Mexico Assume given sequence X = x 1, x 2,..., x m Let Z = z 1, z 2,..., z l Then Z is a subsequence of X if there exists a strictly
More informationDynamic Programming Algorithms
Dynamic Programming Algorithms Introduction In our study of divide-and-conquer algorithms, we noticed that a problem seemed conducive to a divide-and-conquer approach provided 1. it could be divided into
More informationGraphs Introduction and Depth first algorithm
Graphs Introduction and Depth first algorithm Carol Zander Introduction to graphs Graphs are extremely common in computer science applications because graphs are common in the physical world. Everywhere
More informationCMPSCI 311: Introduction to Algorithms Practice Final Exam
CMPSCI 311: Introduction to Algorithms Practice Final Exam Name: ID: Instructions: Answer the questions directly on the exam pages. Show all your work for each question. Providing more detail including
More informationD. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.
CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to convert an array, with priorities stored at subscripts through n,
More informationGreedy Algorithms. CLRS Chapters Introduction to greedy algorithms. Design of data-compression (Huffman) codes
Greedy Algorithms CLRS Chapters 16.1 16.3 Introduction to greedy algorithms Activity-selection problem Design of data-compression (Huffman) codes (Minimum spanning tree problem) (Shortest-path problem)
More informationCSE 417 Dynamic Programming (pt 4) Sub-problems on Trees
CSE 417 Dynamic Programming (pt 4) Sub-problems on Trees Reminders > HW4 is due today > HW5 will be posted shortly Dynamic Programming Review > Apply the steps... 1. Describe solution in terms of solution
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 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 informationDynamic Programming. Introduction, Weighted Interval Scheduling, Knapsack. Tyler Moore. Lecture 15/16
Dynamic Programming Introduction, Weighted Interval Scheduling, Knapsack Tyler Moore CSE, SMU, Dallas, TX Lecture /6 Greedy. Build up a solution incrementally, myopically optimizing some local criterion.
More informationCSE 417 Branch & Bound (pt 4) Branch & Bound
CSE 417 Branch & Bound (pt 4) Branch & Bound Reminders > HW8 due today > HW9 will be posted tomorrow start early program will be slow, so debugging will be slow... Review of previous lectures > Complexity
More information& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n
CSE Name Test Summer 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 C. "% n B. " max( m,n, p). The
More informationGraphs & Digraphs Tuesday, November 06, 2007
Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements
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 information