4.4 Recurrences and Big-O

Size: px
Start display at page:

Download "4.4 Recurrences and Big-O"

Transcription

1 4.4. RECURRENCES AND BIG-O Recurrences and Big-O In this section, we will extend our knowledge of recurrences, showing how to solve recurrences with big-o s in them, recurrences in which n b k, and those that do not fit the master theorem. Big-O in Recurrences We have been discussing recurrences where the non-recursive term is something like n or n.however, when talking about algorithms, it is common to have recurrences where the non-recursive term is O(n) oro(n ). We may also have recurrences where the non-recursive term is Θ(n) or Θ(n ) What does at (n/b) + O(g(n)) mean? Is it really an equation? 4.4- Carefully prove by induction that has a solution of the form O(n log n). T (n/) + O(n) if n O(1) if n =1 In order to understand what Exercise means, we have to think about using the definition of big-o, and our interpretation from recursion trees. This interpretation says that in order to solve a problem of size n, we must solve recursively a problems of size n/b and do O(g(n)) additional work. In other words, there exist positive constants c and n 0, such that the amount of work we have to do is at most cg(n), as long as n>n 0. We don t know what the this n 0 is either, and we will just assume, for now, that it is 1. Now, the amount of work for a problem of size n is not cg(n), but at most cg(n), so we rewrite the recurrence as T (n) at (n/b)+cn, for some constant c. We say for some constant c, because we know that there is a constant c that is implicit in the definition of the big-o. We don t know what this constant is, but we know that it exists and is well-defined. We could still solve such a recurrence with a recursion tree, replacing work with an upper bound on work cg(n) on the first level, etc. We can also use the method we used a few lectures ago, guessing the solution and verifying by induction. We use this method for the recurrence in Exercise Here we wish to show that O(n log n). From the definion of big-o, we see that our recurrence has the form T (n/) + cn if n T (n) O(1) if n =1, for some positive real number c. Ussing the definition of big-o again, we can see that we wish to show that T (n) kn log n for some positive constant k. To prove that T (n) kn log n, we start with a base case. If we choose n = 1, we get T (1) k1log1 or T (1) 0. But we said that T (1) = O(1) so this is actually false. Fortunately

2 9 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES we are ultimately trying to prove a big-o statement about T (n) so our bound doesn t have to hold for all n, justforn>n 0. So choosing n 0 = 1, we have a base case of. When n = the right side of our desired inequality T (n) kn log n becomes kn log n =klog = k. Comparing this with T(), we see that as long as we choose k>t()/, our base case will hold. For the general case, we assume that for n <n, T (n ) kn log n. Now we will bound T (n) using the inductive hypothesis in the second inequality below: T (n) T (n/) + cn k(n/) log(n/) + cn kn log n kn log + cn = kn log n +(c k)n. So our proof will work as long as kn log n +(c k)n <knlog n which is equivalent to (c k)n 0 or k c. But this is fine, because we get to pick the k, so we will pick it to be any value larger than c. We will also pick it so that k>t()/, because of the base case. In other words, we know that O(n log n) because, for whatever constant is implicit in the O(g(n)), we can choose a larger constant to make the statement O(n log n) true. In this case, if we choose k =maxt ()/,c, we will have chosen correctly. This order of picking constants occurs in all these types of proofs. This order holds because we are given O(g(n)) in the recurrence, therefore we know that there exists a constant c such that the O(g(n)) is really at most cg(n). This is true regardless of what recurrence we have for T. We are trying to prove a big-o statement about T (n), so in this case we must show that there exists a constant k with T (n) k(something); because c is independent of T we can define k in terms of c. Recurrences for general n So far, for a recurrence of the form at (n/b)+g(n), we have assumed that n is an integral power of b. This is very convenient because it means that every subproblem that we see is of integral size. Of course, not all problems are of a nice size like this, and we would like a method that works for all n. If you are willing to drop the analogy between recursion trees and recursive algorithms, and just think about recursion trees, you see that we never actually required that the subproblems be of integral size. We can also extend the recursion tree method to deal with the number of problems being non-integral too. Again we have to think a bit more abstractly and all the possibility of fractional sized subproblems. We will not pursue the details here. In fact there is another simple solution to the problem that n may not be a power of b. Since we are only concerned with the solution to T (n) in big-o terms, that is, up to constant factors, the value of T (n) and the value of T (bn) are often not too far apart. In the lemma that follows, we capture the idea of T (n) andt (bn) not being too far apart by the condition that T (bn) =O(T (n). When we say T (x) =O(1) if 0 x<b,wearesayingthatt (x) is bounded by a constant on the whole interval. This is slightly different from the way we have used big Oh notation before, but is quite common. Lemma Let a and b be positive real numbers with b>1 and let f : R + R + be a function such that f(bx) =O(f(x)). Then for any solution t(x) to the recurrence at(x/b)+f(x) if x b t(x) O(1) if 0 x<b,

3 4.4. RECURRENCES AND BIG-O 93 t(x) =O(h(x)) if for every solution T(x) to the recurrence we have T (x) =O(h(x)). T (b n ) at (b n /b)+f(b n ) if n 0 O(1) if n =0, To prove the lemma we would simply write down the result of iterating both recurrences and compare them; a recursion tree would also illustrate this process. Notice that this lemma relies on a condition on f. We note that this condition holds for all polynomially bounded functions. We have been sloppy in our use of recurrences in that we have not paid attention to floors and ceilings. If we allow n to not be a power of b this becomes an issue. We can see that by taking floors, we can never cause a problem, as values only get smaller with floors. We can also show that, even if we take ceilings (as any algorithm that does provide a perfectly even split must do), our recurrences still have the same solutions. Lemma 4.4. Let a and b be positive real numbers with b and let f : R + R + be a function such that f(bx) =O(f(x)). Then for any solution t(x) to the recurrence t(x) at( x/b )+f( x ) if x b O(1) if 0 x<b, t(x) =O(h(x)) if for every solution T(x) to the recurrence we have T (x) =O(h(x)). T (x) at (x/b)+f(x) if x b O(1) if 0 x<b, The proof of this lemma is essentially the same as the proof of the previous one. One can actually show that this is true even with b 1, see CLR for details. Further wrinkles Show by induction that for any solution T (n) to the following recurrence, O(n): T (n/3) + O(n) if n 3 O(1) otherwise Show by induction that for any solution T (n) to the following recurrence, O(n ): 4T (n/) + O(n) if n O(1) otherwise

4 94 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES Implicit in the recursive statement of Exercise that T (n/3)+o(n) is the existence of two constants n 0 and c such that T (n) T (n/3) + cn if n>n 0. For the sake of your intuition, imagine that these ocnstants are in sealed envelopes that we may not open until after we have solved the problem. Since we know they are in the envelopes, we may use the symbols that stand for them in any way we want. In particular, since we want to show that O(n), we want to find two more constants n 0 and k such that T (n) kn whenever n>n 0.Sinceweknowthat the constants c and n 0 exist (they are in the envelope, after all), we can use them if we need to in describing k and n 0. There are two ways to finish Exercise One uses Lemma and one does not. We will outline both ways so you can see the diffference. We begin with the version that does not use the Lemma. Since the exercise did not tell us to assume n is a power of 3, we observe that we can reach many different numbers in the range 1 x<3 by dividing larger integers by higher and higher powers of 3. Thus for our base case we have to consider all numbers x with 1 x<3. The base case of the recurrence tells us that there is some constant q such that T (x) q for 1 x<3. Thus T (x) qx for 1 x<3 because x 1. Thus one possible value for k is q. Now we don t know what k is yet, so it is rather frustrating to be trying to prove something about it. Instead, let us experiment with assuming someone else has witten down a good k in yet another envelope and see if we can figure out anything about what they wrote, or whether it doesn t matter what they wrote and k = q will work just fine. Thus we assume we know that T (y) <kywhen 3 y x/3. Then by this assumption and our recurrence, T (x) k(x/3) + cx/3 =kx kx/3+cx = kx +(c k/3)x. (4.18) We can see from this that if we choose k =3c/ or any bigger number, then an inductive proof should work out because then the coefficient of x will be 0 or negative.. But how did we know that we should write the equalities we did in Equation 4.18? Since we were trying to get T (x) kx, it made sense to write kx kx/3 inplaceofkx/3, and combining the c with the k/3 wasa rather natural piece of arithmetic. However this is not really our proof. We will now prove by induction that T (n/3) + O(n) if n 3 O(1) otherwise. Since dividing an integer value by 3 can give a non-integer value, we prove the recurrence for values x that are an integer divided by a power of 3. We are given that there is a constant q>0 such that T (x) q if 1 x<3. We also know that there is an n 0 such that T (x) T (x/3) + cx for x>n 0. Further, for a given x with 3 x n 0, there are only a finite number of values of x/3 i that are larger than or equal to 3. Thus, given x we let k be the largest of q, 3c/ andthe values T (x/3 i )for3 x/3 i n 0. Then by the choice of k, T (y) ky when 1 y<n 0.Nowif x>n 0 assume inductively that when y = x/3 wehavet (y) ky. Then T (x) T (x/3) + cx k(x/3) + cx = kx +(c k/3)x kx, since (c k/3) is negative or zero because k 3c/. Therefore by the principle of mathematical induction, T (x) kx for all real numbers x 1, so that T (x) =O(x). Here is a new way that we are using mathematical induction. Because for any real number x the sequence of values x/3 i that are greater than 1 is finite, we can apply mathematical induction to reason about the terms

5 4.4. RECURRENCES AND BIG-O 95 of this sequence. (Notice that we never had to specify n 0. Thus we are taking n 0 to be 1. We could have simplified the choice of k somewhat had we taken n 0 to be n 0. Then we could have chosen for k the larger of 3c/ andt (x/3 i ) for the smallest i such that x/3 i n 0. Ignore this parenthetical comment if it confuses you!) If we decide to use Lemma 4.4.1, we can procede in Exercise as before. We are given the constants q, n 0 and c already. We are only going to prove our recurrence for values of n that arepowersof3. Wewishtoprovetherearepositiveconstantsn 0 and k such that T (n) kn for all n>n 0. We will choose n 0 = 1 here. As above, if we assume T (n) kn, wecanwrite T (n) T (n/3) + cn k(n/3) + cn = kn +(c k 3 )n In this case, as long as c k 3 0, the inductive step proof will be correct. Now we choose k to be the largest of the maximum of T (n) for1 n n 0, q, and3c/. To prove by induction that T (x) kx we begin by observing that when 1 n n 0 we have T (n) T (n) 1 kn. Next we assume inductively that n>n 0 and for m with 1 m<nwe have T (m) km. Nowwemaywrite T (n) T (n/3) + cn kn/3+cn = kn +(c k/3)n kn, becausewechosek to be at least as large as 3c/, making c k/3 negative or zero. Thus by the principle of mathematical induction we have T (n) kn for all n 1andsoO(n). Now let s analyze Exercise We won t dot all the i s and cross all the t s here because there is only one major difference between this exercise and the previous one. Let c be the constant implicit in the O(n). We wish to prove there are a n 0 and a k that T (n) kn for n>n 0. Assuming that the base case holds, we can bound T (n) inductively as follows: ( ) n T (n) 4T + cn ( ) n 4(k )+cn ( ) kn = 4 + cn 4 = kn + cn. To procede as before, we would like to choose a value of k so that cn < 0. But we see that we have a problem because both c and n are always positive! What went wrong? We have a statement that we know is true, and we have a proof method (induction) that worked nicely for similar problems. The problem is that, while the statment is true, it is too weak to be proved by induction. Let s try to prove something that is actually stronger, namely that for some positive constants k 1 and k, T (n) k 1 n k n. Now proceding as before, we get T (n) 4T (n/) + cn

6 96 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES ( ) n ( ) n 4(k 1 k )+cn ( k1 n ( ) ) n = 4 k + cn 4 = k 1 n k n + cn = k 1 n k n +(c k )n. Nowwehavetomake(c k )n>0 for the last line to be at most k 1 n k n, and so we just choose k <c.sincet (n) k 1 n + k n for some constants k 1 and k,thent(n) =O(n ). At first glance, this seems like a paradox: why is it easier to prove a stronger statement than it is to prove a weaker one. This phenomenom happens often in mathematics: a stronger statement is often easier to prove than a weaker one. It happens particularly often when using induction. Think carefully about an inductive proof where you have assumed that a bound holds forvaluessmallerthann and you are trying to prove a statement for n. You use the bound you have proved for smaller values to help prove the bound for n Thus if the bound you used for smaller values is actually weak, then that is hindering you in proving the bound for n. Inother words when you want to prove something about p(n) you are using p(1)... p(n 1). Thus if these are stronger, they will be of greater help in proving p(n). In the case above, the problem was that these values, p(1)...p(n 1) were too weak, and thus we were not able to prove p(n). By using a stronger p(1)...p(n 1), however, we were able to prove p(n). Functions other than n c It is also common to see recurrences in with the additional term is not of the form n c, but of some other form. The most common such is example is when that term has logarithms. For example, consider the recurrence: T (n/) + n log n if n>1. O(1) n = 1 Just as before, we can draw a recursiont tree; the whole methodolgy works, but our sums may be a little more complicated. The tree for this recurrence is as follows. Problem Size Work n n log n levels n/ n/4 n/ log(n/) + n/ log(n/) = n log(n/) 4(n/4 log(n/4)) = n log(n/4) n/8 8(n/8 log(n/8)) = n log(n/8) 1 n( n/n log(n/n)) = n

7 4.4. RECURRENCES AND BIG-O 97 This is similar to the tree for T (n/) + n, except that the work for a problem of size i is ilogi. Thus if we sum the work and evaluate the sum we get log n ( ) n n log i log n ( ) n = n log i log n = n (log n log i ) log n log n = n( log n log i ) log n = n(log n(log n +1)+ i) = n(log n(log n +1)+log n(log n +1)/) = O(n log n) As another example consider the recurrence T (n/) + n log n if n>1 O(1) if n =1. The tree for this recurrence is Problem Size Work n n log n levels n/ n/4 n/ log(n/) n/4 log(n4) n/8 n/8 log(n/8) 1 1 Summing the work, we get log n ( ) n n i log i log n 1 = n i (log n log i ) = n(log n log n n(log n()) = O(n log n). ( 1 ) i ( i i )

8 98 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES Exercises E4.4-1 Find the best big-oh upper bound you can to any solution to the recurrence T ( n/ +1)+O(n) if n 4 O(1) if n<4. E4.4- Find the best big-oh upper bound you can to any solution to the recurrence 4T (n/) + n log n if n>1 O(1) if n =1. E4.4-3 Give an example of a function for which f(bx) =O(f(x)). Give an example of a function for which f(bx) isnoto(f(x)). E4.4-4 Show by induction that has O(n 3 ) for any solution T (n). 8T (n/) + n log n if n>1 O(1) if n =1 E4.4-5 Show by induction that any solution to a recurrence of the form T (n/3) + O(log3 n) if n 3 O(1) if 1 n<3 is O(n log 3 n). What happens if you replace by 3 (explain why)? Would it make a difference if we used a different base for the logarithm (only an intuitive explanation is needed here). E4.4-6 What happens if you replace the in the previous exercise by 4? replace the log 3 by log b? (Use recursion trees.) What if you

Big-oh stuff. You should know this definition by heart and be able to give it,

Big-oh stuff. You should know this definition by heart and be able to give it, Big-oh stuff Definition. if asked. You should know this definition by heart and be able to give it, Let f and g both be functions from R + to R +. Then f is O(g) (pronounced big-oh ) if and only if there

More information

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms.

Solving recurrences. Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms. Solving recurrences Frequently showing up when analysing divide&conquer algorithms or, more generally, recursive algorithms Example: Merge-Sort(A, p, r) 1: if p < r then 2: q (p + r)/2 3: Merge-Sort(A,

More information

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2 In-Class Soln 1 Let f(n) be an always positive function and let g(n) = f(n) log n. Show that f(n) = o(g(n)) CS 361, Lecture 4 Jared Saia University of New Mexico For any positive constant c, we want to

More information

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation: CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe

More information

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d

b + O(n d ) where a 1, b > 1, then O(n d log n) if a = b d d ) if a < b d O(n log b a ) if a > b d CS161, Lecture 4 Median, Selection, and the Substitution Method Scribe: Albert Chen and Juliana Cook (2015), Sam Kim (2016), Gregory Valiant (2017) Date: January 23, 2017 1 Introduction Last lecture, we

More information

Asymptotic Analysis and Recurrences

Asymptotic Analysis and Recurrences Appendix A Asymptotic Analysis and Recurrences A.1 Overview We discuss the notion of asymptotic analysis and introduce O, Ω, Θ, and o notation. We then turn to the topic of recurrences, discussing several

More information

Growth of Functions (CLRS 2.3,3)

Growth of Functions (CLRS 2.3,3) Growth of Functions (CLRS 2.3,3) 1 Review Last time we discussed running time of algorithms and introduced the RAM model of computation. Best-case running time: the shortest running time for any input

More information

Lecture 3. Big-O notation, more recurrences!!

Lecture 3. Big-O notation, more recurrences!! Lecture 3 Big-O notation, more recurrences!! Announcements! HW1 is posted! (Due Friday) See Piazza for a list of HW clarifications First recitation section was this morning, there s another tomorrow (same

More information

Algorithms Design & Analysis. Analysis of Algorithm

Algorithms Design & Analysis. Analysis of Algorithm Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of

More information

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm:

The maximum-subarray problem. Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: The maximum-subarray problem Given an array of integers, find a contiguous subarray with the maximum sum. Very naïve algorithm: Brute force algorithm: At best, θ(n 2 ) time complexity 129 Can we do divide

More information

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort

Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map

More information

Methods for solving recurrences

Methods for solving recurrences Methods for solving recurrences Analyzing the complexity of mergesort The merge function Consider the following implementation: 1 int merge ( int v1, int n1, int v, int n ) { 3 int r = malloc ( ( n1+n

More information

Introduction to Divide and Conquer

Introduction to Divide and Conquer Introduction to Divide and Conquer Sorting with O(n log n) comparisons and integer multiplication faster than O(n 2 ) Periklis A. Papakonstantinou York University Consider a problem that admits a straightforward

More information

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:

When we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation: CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe

More information

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation:

Data structures Exercise 1 solution. Question 1. Let s start by writing all the functions in big O notation: Data structures Exercise 1 solution Question 1 Let s start by writing all the functions in big O notation: f 1 (n) = 2017 = O(1), f 2 (n) = 2 log 2 n = O(n 2 ), f 3 (n) = 2 n = O(2 n ), f 4 (n) = 1 = O

More information

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence. Solving Recurrences Recurrences and Recursive Code Many (perhaps most) recursive algorithms fall into one of two categories: tail recursion and divide-andconquer recursion. We would like to develop some

More information

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Catie Baker Spring 2015 CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Catie Baker Spring 2015 Today Registration should be done. Homework 1 due 11:59pm next Wednesday, April 8 th. Review math

More information

Divide and Conquer. Arash Rafiey. 27 October, 2016

Divide and Conquer. Arash Rafiey. 27 October, 2016 27 October, 2016 Divide the problem into a number of subproblems Divide the problem into a number of subproblems Conquer the subproblems by solving them recursively or if they are small, there must be

More information

1 Substitution method

1 Substitution method Recurrence Relations we have discussed asymptotic analysis of algorithms and various properties associated with asymptotic notation. As many algorithms are recursive in nature, it is natural to analyze

More information

Lecture 10: Big-Oh. Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette. January 27, 2014

Lecture 10: Big-Oh. Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette. January 27, 2014 Lecture 10: Big-Oh Doina Precup With many thanks to Prakash Panagaden and Mathieu Blanchette January 27, 2014 So far we have talked about O() informally, as a way of capturing the worst-case computation

More information

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018

Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of

More information

Proof Techniques (Review of Math 271)

Proof Techniques (Review of Math 271) Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil

More information

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0

Asymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0 Asymptotic Notation Asymptotic notation deals with the behaviour of a function in the limit, that is, for sufficiently large values of its parameter. Often, when analysing the run time of an algorithm,

More information

Reading and Writing. Mathematical Proofs. Slides by Arthur van Goetham

Reading and Writing. Mathematical Proofs. Slides by Arthur van Goetham Reading and Writing Mathematical Proofs Slides by Arthur van Goetham What is a proof? Why explanations are not proofs What is a proof? A method for establishing truth What establishes truth depends on

More information

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence.

Solving Recurrences. 1. Express the running time (or use of some other resource) as a recurrence. 1 Recurrences and Recursive Code Solving Recurrences Many (perhaps most) recursive algorithms fall into one of two categories: tail recursion and divide-andconquer recursion. We would like to develop some

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

More information

CSC236 Week 4. Larry Zhang

CSC236 Week 4. Larry Zhang CSC236 Week 4 Larry Zhang 1 Announcements PS2 due on Friday This week s tutorial: Exercises with big-oh PS1 feedback People generally did well Writing style need to be improved. This time the TAs are lenient,

More information

Recurrence Relations

Recurrence Relations Recurrence Relations Analysis Tools S.V. N. (vishy) Vishwanathan University of California, Santa Cruz vishy@ucsc.edu January 15, 2016 S.V. N. Vishwanathan (UCSC) CMPS101 1 / 29 Recurrences Outline 1 Recurrences

More information

Computational Complexity

Computational Complexity Computational Complexity S. V. N. Vishwanathan, Pinar Yanardag January 8, 016 1 Computational Complexity: What, Why, and How? Intuitively an algorithm is a well defined computational procedure that takes

More information

The Growth of Functions. A Practical Introduction with as Little Theory as possible

The Growth of Functions. A Practical Introduction with as Little Theory as possible The Growth of Functions A Practical Introduction with as Little Theory as possible Complexity of Algorithms (1) Before we talk about the growth of functions and the concept of order, let s discuss why

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Lecture 6-8 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: STII, Room 443, Friday 4:00pm - 6:00pm or by appointments

More information

Mergesort and Recurrences (CLRS 2.3, 4.4)

Mergesort and Recurrences (CLRS 2.3, 4.4) Mergesort and Recurrences (CLRS 2.3, 4.4) We saw a couple of O(n 2 ) algorithms for sorting. Today we ll see a different approach that runs in O(n lg n) and uses one of the most powerful techniques for

More information

CS383, Algorithms Spring 2009 HW1 Solutions

CS383, Algorithms Spring 2009 HW1 Solutions Prof. Sergio A. Alvarez http://www.cs.bc.edu/ alvarez/ 21 Campanella Way, room 569 alvarez@cs.bc.edu Computer Science Department voice: (617) 552-4333 Boston College fax: (617) 552-6790 Chestnut Hill,

More information

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010

Announcements. CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis. Today. Mathematical induction. Dan Grossman Spring 2010 Announcements CSE332: Data Abstractions Lecture 2: Math Review; Algorithm Analysis Dan Grossman Spring 2010 Project 1 posted Section materials on using Eclipse will be very useful if you have never used

More information

CS483 Design and Analysis of Algorithms

CS483 Design and Analysis of Algorithms CS483 Design and Analysis of Algorithms Chapter 2 Divide and Conquer Algorithms Instructor: Fei Li lifei@cs.gmu.edu with subject: CS483 Office hours: Room 5326, Engineering Building, Thursday 4:30pm -

More information

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models Contents Mathematical Reasoning 3.1 Mathematical Models........................... 3. Mathematical Proof............................ 4..1 Structure of Proofs........................ 4.. Direct Method..........................

More information

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013

Big O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013 /4/3 Administrative Big O David Kauchak cs3 Spring 3 l Assignment : how d it go? l Assignment : out soon l CLRS code? l Videos Insertion-sort Insertion-sort Does it terminate? /4/3 Insertion-sort Loop

More information

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2

Grade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2 1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 5 Recurrences, Part 2 Running time of algorithms In computer science,

More information

Asymptotic Analysis. Thomas A. Anastasio. January 7, 2004

Asymptotic Analysis. Thomas A. Anastasio. January 7, 2004 Asymptotic Analysis Thomas A. Anastasio January 7, 004 1 Introduction As a programmer, you often have a choice of data structures and algorithms. Choosing the best one for a particular job involves, among

More information

Data Structures and Algorithms Chapter 3

Data Structures and Algorithms Chapter 3 Data Structures and Algorithms Chapter 3 1. Divide and conquer 2. Merge sort, repeated substitutions 3. Tiling 4. Recurrences Recurrences Running times of algorithms with recursive calls can be described

More information

Tutorial on Mathematical Induction

Tutorial on Mathematical Induction Tutorial on Mathematical Induction Roy Overbeek VU University Amsterdam Department of Computer Science r.overbeek@student.vu.nl April 22, 2014 1 Dominoes: from case-by-case to induction Suppose that you

More information

3.1 Asymptotic notation

3.1 Asymptotic notation 3.1 Asymptotic notation The notations we use to describe the asymptotic running time of an algorithm are defined in terms of functions whose domains are the set of natural numbers N = {0, 1, 2,... Such

More information

Reading 10 : Asymptotic Analysis

Reading 10 : Asymptotic Analysis CS/Math 240: Introduction to Discrete Mathematics Fall 201 Instructor: Beck Hasti and Gautam Prakriya Reading 10 : Asymptotic Analysis In the last reading, we analyzed the running times of various algorithms.

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents

More information

Omega notation. Transitivity etc.

Omega notation. Transitivity etc. Omega notation Big-Omega: Lecture 2, Sept. 25, 2014 f () n (()) g n const cn, s.t. n n : cg() n f () n Small-omega: 0 0 0 f () n (()) g n const c, n s.t. n n : cg() n f () n 0 0 0 Intuition (works most

More information

Chapter 1 Review of Equations and Inequalities

Chapter 1 Review of Equations and Inequalities Chapter 1 Review of Equations and Inequalities Part I Review of Basic Equations Recall that an equation is an expression with an equal sign in the middle. Also recall that, if a question asks you to solve

More information

MATH 22 FUNCTIONS: ORDER OF GROWTH. Lecture O: 10/21/2003. The old order changeth, yielding place to new. Tennyson, Idylls of the King

MATH 22 FUNCTIONS: ORDER OF GROWTH. Lecture O: 10/21/2003. The old order changeth, yielding place to new. Tennyson, Idylls of the King MATH 22 Lecture O: 10/21/2003 FUNCTIONS: ORDER OF GROWTH The old order changeth, yielding place to new. Tennyson, Idylls of the King Men are but children of a larger growth. Dryden, All for Love, Act 4,

More information

1 Closest Pair of Points on the Plane

1 Closest Pair of Points on the Plane CS 31: Algorithms (Spring 2019): Lecture 5 Date: 4th April, 2019 Topic: Divide and Conquer 3: Closest Pair of Points on a Plane Disclaimer: These notes have not gone through scrutiny and in all probability

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali March 17, 2014 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine solutions

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17 601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Asymptotic Analysis, recurrences Date: 9/7/17 2.1 Notes Homework 1 will be released today, and is due a week from today by the beginning

More information

1 Divide and Conquer (September 3)

1 Divide and Conquer (September 3) The control of a large force is the same principle as the control of a few men: it is merely a question of dividing up their numbers. Sun Zi, The Art of War (c. 400 C.E.), translated by Lionel Giles (1910)

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 14, 2019 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. COMP

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 10, 2018 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. 1 /

More information

CS 161 Summer 2009 Homework #2 Sample Solutions

CS 161 Summer 2009 Homework #2 Sample Solutions CS 161 Summer 2009 Homework #2 Sample Solutions Regrade Policy: If you believe an error has been made in the grading of your homework, you may resubmit it for a regrade. If the error consists of more than

More information

A design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101

A design paradigm. Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/ EECS 3101 A design paradigm Divide and conquer: (When) does decomposing a problem into smaller parts help? 09/09/17 112 Multiplying complex numbers (from Jeff Edmonds slides) INPUT: Two pairs of integers, (a,b),

More information

Data Structures and Algorithms CMPSC 465

Data Structures and Algorithms CMPSC 465 Data Structures and Algorithms CMPSC 465 LECTURE 9 Solving recurrences Substitution method Adam Smith S. Raskhodnikova and A. Smith; based on slides by E. Demaine and C. Leiserson Review question Draw

More information

CS173 Strong Induction and Functions. Tandy Warnow

CS173 Strong Induction and Functions. Tandy Warnow CS173 Strong Induction and Functions Tandy Warnow CS 173 Introduction to Strong Induction (also Functions) Tandy Warnow Preview of the class today What are functions? Weak induction Strong induction A

More information

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016 CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis Hunter Zahn Summer 2016 Today Finish discussing stacks and queues Review math essential to algorithm analysis Proof by

More information

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt

What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency Asympt Lecture 3 The Analysis of Recursive Algorithm Efficiency What we have learned What is algorithm Why study algorithm The time and space efficiency of algorithm The analysis framework of time efficiency

More information

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30,

Divide and Conquer. CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, Divide and Conquer CSE21 Winter 2017, Day 9 (B00), Day 6 (A00) January 30, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Merging sorted lists: WHAT Given two sorted lists a 1 a 2 a 3 a k b 1 b 2 b 3 b

More information

This chapter covers asymptotic analysis of function growth and big-o notation.

This chapter covers asymptotic analysis of function growth and big-o notation. Chapter 14 Big-O This chapter covers asymptotic analysis of function growth and big-o notation. 14.1 Running times of programs An important aspect of designing a computer programs is figuring out how well

More information

CS 5321: Advanced Algorithms - Recurrence. Acknowledgement. Outline. Ali Ebnenasir Department of Computer Science Michigan Technological University

CS 5321: Advanced Algorithms - Recurrence. Acknowledgement. Outline. Ali Ebnenasir Department of Computer Science Michigan Technological University CS 5321: Advanced Algorithms - Recurrence Ali Ebnenasir Department of Computer Science Michigan Technological University Acknowledgement Eric Torng Moon Jung Chung Charles Ofria Outline Motivating example:

More information

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016

Divide and Conquer. Maximum/minimum. Median finding. CS125 Lecture 4 Fall 2016 CS125 Lecture 4 Fall 2016 Divide and Conquer We have seen one general paradigm for finding algorithms: the greedy approach. We now consider another general paradigm, known as divide and conquer. We have

More information

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms

CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions

More information

CSCI 3110 Assignment 6 Solutions

CSCI 3110 Assignment 6 Solutions CSCI 3110 Assignment 6 Solutions December 5, 2012 2.4 (4 pts) Suppose you are choosing between the following three algorithms: 1. Algorithm A solves problems by dividing them into five subproblems of half

More information

Lecture 10: Powers of Matrices, Difference Equations

Lecture 10: Powers of Matrices, Difference Equations Lecture 10: Powers of Matrices, Difference Equations Difference Equations A difference equation, also sometimes called a recurrence equation is an equation that defines a sequence recursively, i.e. each

More information

Egyptian Fractions: Part I

Egyptian Fractions: Part I Egyptian Fractions: Part I Prepared by: Eli Jaffe October 8, 2017 1 Cutting Cakes 1. Imagine you are a teacher. Your class of 10 students is on a field trip to the bakery. At the end of the tour, the baker

More information

CS 5321: Advanced Algorithms Analysis Using Recurrence. Acknowledgement. Outline

CS 5321: Advanced Algorithms Analysis Using Recurrence. Acknowledgement. Outline CS 5321: Advanced Algorithms Analysis Using Recurrence Ali Ebnenasir Department of Computer Science Michigan Technological University Acknowledgement Eric Torng Moon Jung Chung Charles Ofria Outline Motivating

More information

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2

MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2 MA008 p.1/36 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/36 Content of lecture 2 Examples Review data structures Data types vs. data

More information

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018 CS 61B More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018 Here is a review of some formulas that you will find useful when doing asymptotic analysis. ˆ N i=1 i = 1 + 2 + 3 + 4 + + N = N(N+1)

More information

Analysis of Algorithms - Using Asymptotic Bounds -

Analysis of Algorithms - Using Asymptotic Bounds - Analysis of Algorithms - Using Asymptotic Bounds - Andreas Ermedahl MRTC (Mälardalens Real-Time Research Center) andreas.ermedahl@mdh.se Autumn 004 Rehersal: Asymptotic bounds Gives running time bounds

More information

Writing proofs. Tim Hsu, San José State University. May 31, Definitions and theorems 3. 2 What is a proof? 3. 3 A word about definitions 4

Writing proofs. Tim Hsu, San José State University. May 31, Definitions and theorems 3. 2 What is a proof? 3. 3 A word about definitions 4 Writing proofs Tim Hsu, San José State University May 31, 2006 Contents I Fundamentals 3 1 Definitions and theorems 3 2 What is a proof? 3 3 A word about definitions 4 II The structure of proofs 6 4 Assumptions

More information

At the start of the term, we saw the following formula for computing the sum of the first n integers:

At the start of the term, we saw the following formula for computing the sum of the first n integers: Chapter 11 Induction This chapter covers mathematical induction. 11.1 Introduction to induction At the start of the term, we saw the following formula for computing the sum of the first n integers: Claim

More information

Nondeterministic finite automata

Nondeterministic finite automata Lecture 3 Nondeterministic finite automata This lecture is focused on the nondeterministic finite automata (NFA) model and its relationship to the DFA model. Nondeterminism is an important concept in the

More information

A SUMMARY OF RECURSION SOLVING TECHNIQUES

A SUMMARY OF RECURSION SOLVING TECHNIQUES A SUMMARY OF RECURSION SOLVING TECHNIQUES KIMMO ERIKSSON, KTH These notes are meant to be a complement to the material on recursion solving techniques in the textbook Discrete Mathematics by Biggs. In

More information

CONSTRUCTION OF THE REAL NUMBERS.

CONSTRUCTION OF THE REAL NUMBERS. CONSTRUCTION OF THE REAL NUMBERS. IAN KIMING 1. Motivation. It will not come as a big surprise to anyone when I say that we need the real numbers in mathematics. More to the point, we need to be able to

More information

Lecture 1: Asymptotics, Recurrences, Elementary Sorting

Lecture 1: Asymptotics, Recurrences, Elementary Sorting Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running

More information

Lecture 12 : Recurrences DRAFT

Lecture 12 : Recurrences DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/1/2011 Lecture 12 : Recurrences Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last few classes we talked about program correctness. We

More information

CS1800: Strong Induction. Professor Kevin Gold

CS1800: Strong Induction. Professor Kevin Gold CS1800: Strong Induction Professor Kevin Gold Mini-Primer/Refresher on Unrelated Topic: Limits This is meant to be a problem about reasoning about quantifiers, with a little practice of other skills, too

More information

The Inductive Proof Template

The Inductive Proof Template CS103 Handout 24 Winter 2016 February 5, 2016 Guide to Inductive Proofs Induction gives a new way to prove results about natural numbers and discrete structures like games, puzzles, and graphs. All of

More information

Solutions Parabola Volume 49, Issue 2 (2013)

Solutions Parabola Volume 49, Issue 2 (2013) Parabola Volume 49, Issue (013) Solutions 1411 140 Q1411 How many three digit numbers are there which do not contain any digit more than once? What do you get if you add them all up? SOLUTION There are

More information

TAYLOR POLYNOMIALS DARYL DEFORD

TAYLOR POLYNOMIALS DARYL DEFORD TAYLOR POLYNOMIALS DARYL DEFORD 1. Introduction We have seen in class that Taylor polynomials provide us with a valuable tool for approximating many different types of functions. However, in order to really

More information

Another Proof By Contradiction: 2 is Irrational

Another Proof By Contradiction: 2 is Irrational Another Proof By Contradiction: 2 is Irrational Theorem: 2 is irrational. Proof: By contradiction. Suppose 2 is rational. Then 2 = a/b for some a, b N +. We can assume that a/b is in lowest terms. Therefore,

More information

Chapter 2. Recurrence Relations. Divide and Conquer. Divide and Conquer Strategy. Another Example: Merge Sort. Merge Sort Example. Merge Sort Example

Chapter 2. Recurrence Relations. Divide and Conquer. Divide and Conquer Strategy. Another Example: Merge Sort. Merge Sort Example. Merge Sort Example Recurrence Relations Chapter 2 Divide and Conquer Equation or an inequality that describes a function by its values on smaller inputs. Recurrence relations arise when we analyze the running time of iterative

More information

Algebra Exam. Solutions and Grading Guide

Algebra Exam. Solutions and Grading Guide Algebra Exam Solutions and Grading Guide You should use this grading guide to carefully grade your own exam, trying to be as objective as possible about what score the TAs would give your responses. Full

More information

Properties of Arithmetic

Properties of Arithmetic Excerpt from "Prealgebra" 205 AoPS Inc. 4 6 7 4 5 8 22 23 5 7 0 Arithmetic is being able to count up to twenty without taking o your shoes. Mickey Mouse CHAPTER Properties of Arithmetic. Why Start with

More information

Chapter 5 Divide and Conquer

Chapter 5 Divide and Conquer CMPT 705: Design and Analysis of Algorithms Spring 008 Chapter 5 Divide and Conquer Lecturer: Binay Bhattacharya Scribe: Chris Nell 5.1 Introduction Given a problem P with input size n, P (n), we define

More information

Egyptian Fractions: Part I

Egyptian Fractions: Part I Egyptian Fractions: Part I Prepared by: Eli Jaffe October 8, 2017 1 Cutting Cakes 1. Imagine you are a teacher. Your class of 10 students is on a field trip to the bakery. At the end of the tour, the baker

More information

Divide and Conquer Algorithms

Divide and Conquer Algorithms Divide and Conquer Algorithms T. M. Murali February 19, 2013 Divide and Conquer Break up a problem into several parts. Solve each part recursively. Solve base cases by brute force. Efficiently combine

More information

Regression, part II. I. What does it all mean? A) Notice that so far all we ve done is math.

Regression, part II. I. What does it all mean? A) Notice that so far all we ve done is math. Regression, part II I. What does it all mean? A) Notice that so far all we ve done is math. 1) One can calculate the Least Squares Regression Line for anything, regardless of any assumptions. 2) But, if

More information

Some Review Problems for Exam 2: Solutions

Some Review Problems for Exam 2: Solutions Math 5366 Fall 017 Some Review Problems for Exam : Solutions 1 Find the coefficient of x 15 in each of the following: 1 (a) (1 x) 6 Solution: 1 (1 x) = ( ) k + 5 x k 6 k ( ) ( ) 0 0 so the coefficient

More information

5.2 Infinite Series Brian E. Veitch

5.2 Infinite Series Brian E. Veitch 5. Infinite Series Since many quantities show up that cannot be computed exactly, we need some way of representing it (or approximating it). One way is to sum an infinite series. Recall that a n is the

More information

Exercise Sheet #1 Solutions, Computer Science, A M. Hallett, K. Smith a k n b k = n b + k. a k n b k c 1 n b k. a k n b.

Exercise Sheet #1 Solutions, Computer Science, A M. Hallett, K. Smith a k n b k = n b + k. a k n b k c 1 n b k. a k n b. Exercise Sheet #1 Solutions, Computer Science, 308-251A M. Hallett, K. Smith 2002 Question 1.1: Prove (n + a) b = Θ(n b ). Binomial Expansion: Show O(n b ): (n + a) b = For any c 1 > b = O(n b ). Show

More information

Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi

Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 41 Pulse Code Modulation (PCM) So, if you remember we have been talking

More information

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. 2 Arithmetic This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}. (See [Houston, Chapters 27 & 28]) 2.1 Greatest common divisors Definition 2.16. If a, b are integers, we say

More information

Finding the Median. 1 The problem of finding the median. 2 A good strategy? lecture notes September 2, Lecturer: Michel Goemans

Finding the Median. 1 The problem of finding the median. 2 A good strategy? lecture notes September 2, Lecturer: Michel Goemans 18.310 lecture notes September 2, 2013 Finding the Median Lecturer: Michel Goemans 1 The problem of finding the median Suppose we have a list of n keys that are completely unsorted. If we want to find

More information

Chapter 4. Recurrences

Chapter 4. Recurrences Chapter 4. Recurrences Outline Offers three methods for solving recurrences, that is for obtaining asymptotic bounds on the solution In the substitution method, we guess a bound and then use mathematical

More information

Computational Complexity - Pseudocode and Recursions

Computational Complexity - Pseudocode and Recursions Computational Complexity - Pseudocode and Recursions Nicholas Mainardi 1 Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it June 6, 2018 1 Partly Based on Alessandro

More information

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan

Lecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Lecture 2 More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Announcements Assignment #1 is posted online It is directly related to MCSS which we will be talking about today or Monday. There are

More information

P, NP, NP-Complete, and NPhard

P, NP, NP-Complete, and NPhard P, NP, NP-Complete, and NPhard Problems Zhenjiang Li 21/09/2011 Outline Algorithm time complicity P and NP problems NP-Complete and NP-Hard problems Algorithm time complicity Outline What is this course

More information