Analysis of Algorithms CS 372 Why Study Algorithms?

... – A problem is solved by dividing it into smaller problems, solving them independently and combining the solution ...

... – A problem is solved by dividing it into smaller problems, solving them independently and combining the solution ...

Problem 1: (Harmonic numbers) Let Hn be the n harmonic number

... such that removing e disconnects the graph, i.e. breaks the graph into at least two connected components. Give an O(|E|) time algorithm to find all bridge edges of G. Hint: use DFS. Problem 3: (Fast Multiplication) Analyze the traditional multiplication algorithm for two n bit numbers. Now assume a ...

... such that removing e disconnects the graph, i.e. breaks the graph into at least two connected components. Give an O(|E|) time algorithm to find all bridge edges of G. Hint: use DFS. Problem 3: (Fast Multiplication) Analyze the traditional multiplication algorithm for two n bit numbers. Now assume a ...

Introduction to Algorithms

... • Running time: – the number of primitive operations (steps) executed before termination T(n) =1 [first step] + (n) [for loop] + (n-1) [if condition] + (n-1) [the assignment in then] = 3n - 1 ...

... • Running time: – the number of primitive operations (steps) executed before termination T(n) =1 [first step] + (n) [for loop] + (n-1) [if condition] + (n-1) [the assignment in then] = 3n - 1 ...

ANALYSIS OF ALGORITHMS

... Problem : Write pseudo-code for an algorithm that will determine the maximum element from a list (array) ...

... Problem : Write pseudo-code for an algorithm that will determine the maximum element from a list (array) ...

Chapter 3

... • Intractable: The situation is much worse for problems that cannot be solved using an algorithm with worst-case polynomial time complexity. The problems are called intractable. • NP problem. • NP-complete problem. • Unsolvable problem: no algorithm to solve them. ...

... • Intractable: The situation is much worse for problems that cannot be solved using an algorithm with worst-case polynomial time complexity. The problems are called intractable. • NP problem. • NP-complete problem. • Unsolvable problem: no algorithm to solve them. ...

Terminology: Lecture 1 Name:_____________________

... start = time.time() sum = sumList(aList) end = time.time() print "Time to sum the list was %.3f seconds" % (end-start) def sumList(myList): """Returns the sum of all items in myList""" total = 0 for item in myList: total = total + item return total main() ...

... start = time.time() sum = sumList(aList) end = time.time() print "Time to sum the list was %.3f seconds" % (end-start) def sumList(myList): """Returns the sum of all items in myList""" total = 0 for item in myList: total = total + item return total main() ...

Instructor Rubric for Presentations

... afterwards) based on what is presented by your peer. This sheet can also be used as a study-guide for yourself, later on. ...

... afterwards) based on what is presented by your peer. This sheet can also be used as a study-guide for yourself, later on. ...

1 What is the Subset Sum Problem? 2 An Exact Algorithm for the

... An instance of the Subset Sum problem is a pair (S, t), where S = {x1 , x2 , ..., xn } is a set of positive integers and t (the target) is a positive integer. The decision problem asks for a subset of S whose sum is as large as possible, but not larger than t. This problem is NP-complete. This probl ...

... An instance of the Subset Sum problem is a pair (S, t), where S = {x1 , x2 , ..., xn } is a set of positive integers and t (the target) is a positive integer. The decision problem asks for a subset of S whose sum is as large as possible, but not larger than t. This problem is NP-complete. This probl ...

Time Complexity 1

... • Algorithms running efficiently on small instances may run very slowly with large instance sizes • Analysis must capture algorithm behavior when problem instances are large – For example, linear search may not be efficient when the list size n = 1,000,000 ...

... • Algorithms running efficiently on small instances may run very slowly with large instance sizes • Analysis must capture algorithm behavior when problem instances are large – For example, linear search may not be efficient when the list size n = 1,000,000 ...

APPROXIMATION ALGORITHMS

... Method: Faster x[m+1]=D-1[b-(L+U)x[m]] xk[m+1] =(1/akk)(bk-ak1x1[m]-…-aknx1[m]) ...

... Method: Faster x[m+1]=D-1[b-(L+U)x[m]] xk[m+1] =(1/akk)(bk-ak1x1[m]-…-aknx1[m]) ...

solution - cse.sc.edu

... If v c (mod p), accept. Otherwise, reject.” We show that this algorithm runs in polynomial time. Stages 1 and 4 are executed only once. Stage 3 runs O(n) times, which is polynomial in terms of the length of b, and each round of stage 3 can be implemented in constant time. Hence M is a polynomial t ...

... If v c (mod p), accept. Otherwise, reject.” We show that this algorithm runs in polynomial time. Stages 1 and 4 are executed only once. Stage 3 runs O(n) times, which is polynomial in terms of the length of b, and each round of stage 3 can be implemented in constant time. Hence M is a polynomial t ...

1 - USC

... All the timings are in p.m. Courses are said to be compatible if their timings do not overlap. Outline an algorithm so that the CS department can allocate the maximum set of compatible courses to SAL 101. What is the maximum set of compatible courses in the above case? ...

... All the timings are in p.m. Courses are said to be compatible if their timings do not overlap. Outline an algorithm so that the CS department can allocate the maximum set of compatible courses to SAL 101. What is the maximum set of compatible courses in the above case? ...

ComputationalComplex.. - Computer Science & Engineering

... in polynomial time by nondeterministic computers NP Include all problems in P The key question is are there problems in NP that are not in P or is P = NP? We don’t know the answer to the previous question But there are a particular kind of problems, the NP-complete problems, for which all known dete ...

... in polynomial time by nondeterministic computers NP Include all problems in P The key question is are there problems in NP that are not in P or is P = NP? We don’t know the answer to the previous question But there are a particular kind of problems, the NP-complete problems, for which all known dete ...

Decrease-and

... o There are no duplicates in the list. o Since the elements are unique (by assumption), all that matters is their relative rank. Accordingly we identify them with the first N integers {1, 2, ..., N} and assume the elements we have to sort are the first N integers. Under these circumstances we can sa ...

... o There are no duplicates in the list. o Since the elements are unique (by assumption), all that matters is their relative rank. Accordingly we identify them with the first N integers {1, 2, ..., N} and assume the elements we have to sort are the first N integers. Under these circumstances we can sa ...

Here is a factoring algorithm that one of my students, Jay Patel

... Here is a factoring algorithm that one of my students, Jay Patel, showed the class. It is useful when factoring a polynomial with a known zero. Suppose P ( r ) 0 . Since we know ( x r ) is a factor, P ( x ) ( x r )(Q ( x )) , where degree of Q ( x ) is one less than the degree of P ( x ) . W ...

... Here is a factoring algorithm that one of my students, Jay Patel, showed the class. It is useful when factoring a polynomial with a known zero. Suppose P ( r ) 0 . Since we know ( x r ) is a factor, P ( x ) ( x r )(Q ( x )) , where degree of Q ( x ) is one less than the degree of P ( x ) . W ...

Lecture 2 - Rabie A. Ramadan

... significant rate, they quickly dominate the slower-growing functions. This means that if we determine that an algorithm’s complexity is a combination of two of these classes, we will frequently ignore all but the fastest growing of these terms. ...

... significant rate, they quickly dominate the slower-growing functions. This means that if we determine that an algorithm’s complexity is a combination of two of these classes, we will frequently ignore all but the fastest growing of these terms. ...

Document

... Input: A weighted directed graph G=(V,E), where |E|=m and |V|=n. Output: An nn distance matrix. Can be solved in: mn + n2 log n [Johnson ’77] (with Fibonacci Heaps) mn + n2 log log n [Thorup ’99, Hagerup ’00, Pettie ’02] ...

... Input: A weighted directed graph G=(V,E), where |E|=m and |V|=n. Output: An nn distance matrix. Can be solved in: mn + n2 log n [Johnson ’77] (with Fibonacci Heaps) mn + n2 log log n [Thorup ’99, Hagerup ’00, Pettie ’02] ...

Parallel Computation

... • Writing to and reading from the memory takes no time and can be shared • We can use as many processors as we wish (for different instances of the same problem different number of processors can be used), but this number is polynomial in the size of the input - from the point of view of complexity ...

... • Writing to and reading from the memory takes no time and can be shared • We can use as many processors as we wish (for different instances of the same problem different number of processors can be used), but this number is polynomial in the size of the input - from the point of view of complexity ...