# CS 561, Lecture 3 - Recurrences. Jared Saia University of New Mexico

Save this PDF as:

Size: px
Start display at page:

Download "CS 561, Lecture 3 - Recurrences. Jared Saia University of New Mexico"

## Transcription

1 CS 561, Lecture 3 - Recurrences Jared Saia University of New Mexico

2 Recurrence Relations Oh how should I not lust after eternity and after the nuptial ring of rings, the ring of recurrence - Friedrich Nietzsche, Thus Spoke Zarathustra Getting the run times of recursive algorithms can be challenging Consider an algorithm for binary search (next slide) Let T (n) be the run time of this algorithm on an array of size n Then we can write T (1) = 1, T (n) = T (n/2) + 1 1

3 Alg: Binary Search bool BinarySearch (int arr[], int s, int e, int key){ if (e-s<=0) return false; int mid = (e+s)/2; if (key==arr[mid]){ return true; }else if (key < arr[mid]){ return BinarySearch (arr,s,mid,key);} else{ return BinarySearch (arr,mid,e,key)} } 2

4 Recurrence Relations T (n) = T (n/2) + 1 is an example of a recurrence relation A Recurrence Relation is any equation for a function T, where T appears on both the left and right sides of the equation. We always want to solve these recurrence relation by getting an equation for T, where T appears on just the left side of the equation 3

5 Recurrence Relations Whenever we analyze the run time of a recursive algorithm, we will first get a recurrence relation To get the actual run time, we need to solve the recurrence relation 4

6 Substitution Method One way to solve recurrences is the substitution method aka guess and check What we do is make a good guess for the solution to T (n), and then try to prove this is the solution by induction 5

7 Example Let s guess that the solution to T (n) = T (n/2)+1, T (1) = 1 is T (n) = O(log n) In other words, T (n) c log n for all n n 0, for some positive constants c, n 0 We can prove that T (n) c log n is true by plugging back into the recurrence 6

8 Proof We prove this by induction: B.C.: T (2) = 2 c log 2 provided that c 2 I.H.: For all j < n, T (j) c log(j) I.S.: T (n) = T (n/2) + 1 (1) (c log(n/2)) + 1 (2) = c(log n log 2) + 1 (3) = c log n c + 1 (4) c log n (5) Last step holds for all n > 0 if c 1. Thus, entire proof holds if n 2 and c 2. 7

9 Recurrences and Induction Recurrences and Induction are closely related: To find a solution to f(n), solve a recurrence To prove that a solution for f(n) is correct, use induction For both recurrences and induction, we always solve a big problem by reducing it to smaller problems! 8

10 Some Examples The next several problems can be attacked by induction/recurrences For each problem, we ll need to reduce it to smaller problems Question: How can we reduce each problem to a smaller subproblem? 9

11 Sum Problem f(n) is the sum of the integers 1,..., n 10

12 Tree Problem f(n) is the maximum number of leaf nodes in a binary tree of height n Recall: In a binary tree, each node has at most two children A leaf node is a node with no children The height of a tree is the length of the longest path from the root to a leaf node. 11

13 Binary Search Problem f(n) is the maximum number of queries that need to be made for binary search on a sorted array of size n. 12

14 Dominoes Problem f(n) is the number of ways to tile a 2 by n rectangle with dominoes (a domino is a 2 by 1 rectangle) 13

15 Simpler Subproblems Sum Problem: What is the sum of all numbers between 1 and n 1 (i.e. f(n 1))? Tree Problem: What is the maximum number of leaf nodes in a binary tree of height n 1? (i.e. f(n 1)) Binary Search Problem: What is the maximum number of queries that need to be made for binary search on a sorted array of size n/2? (i.e. f(n/2)) Dominoes problem: What is the number of ways to tile a 2 by n 1 rectangle with dominoes? What is the number of ways to tile a 2 by n 2 rectangle with dominoes? (i.e. f(n 1), f(n 2)) 14

16 Recurrences Sum Problem: f(n) = f(n 1) + n, f(1) = 1 Tree Problem: f(n) = 2 f(n 1), f(0) = 1 Binary Search Problem: f(n) = f(n/2) + 1, f(2) = 1 Dominoes problem: f(n) = f(n 1) + f(n 2), f(1) = 1, f(2) = 2 15

17 Guesses Sum Problem: f(n) = (n + 1)n/2 Tree Problem: f(n) = 2 n Binary Search Problem: f(n) = log n Dominoes problem: f(n) = 1 (1+ ) n (1 5 2 ) n 16

18 Inductive Proofs Trying is the first step to failure - Homer Simpson Now that we ve made these guesses, we can try using induction to prove they re correct (the substitution method) We ll give inductive proofs that these guesses are correct for the first three problems 17

19 Sum Problem Want to show that f(n) = (n + 1)n/2. Prove by induction on n Base case: f(1) = 2 1/2 = 1 Inductive hypothesis: for all j < n, f(j) = (j + 1)j/2 Inductive step: f(n) = f(n 1) + n (6) = n(n 1)/2 + n (7) = (n + 1)n/2 (8) 18

20 Tree Problem Want to show that f(n) = 2 n. Prove by induction on n Base case: f(0) = 2 0 = 1 Inductive hypothesis: for all j < n, f(j) = 2 j Inductive step: f(n) = 2 f(n 1) (9) = 2 (2 n 1 ) (10) = 2 n (11) 19

21 Binary Search Problem Want to show that f(n) = log n. (assume n is a power of 2) Prove by induction on n Base case: f(2) = log 2 = 1 Inductive hypothesis: for all j < n, f(j) = log j Inductive step: f(n) = f(n/2) + 1 (12) = log n/2 + 1 (13) = log n log (14) = log n (15) 20

22 In Class Exercise Consider the recurrence f(n) = 2f(n/2) + 1, f(1) = 1 Guess that f(n) cn 1: Q1: Show the base case - for what values of c does it hold? Q2: What is the inductive hypothesis? Q3: Show the inductive step. 21

23 Recurrences and Inequalities Often easier to prove that a recurrence is no more than some quantity than to prove that it equals something Consider: f(n) = f(n 1) + f(n 2), f(1) = f(2) = 1 Guess that f(n) 2 n 22

24 Inequalities (II) Goal: Prove by induction that for f(n) = f(n 1) + f(n 2), f(1) = f(2) = 1, f(n) 2 n Base case: f(1) = 1 2 1, f(2) = Inductive hypothesis: For all j < n, f(j) 2 j Inductive step: f(n) = f(n 1) + f(n 2) (16) 2 n n 2 (17) < 2 2 n 1 (18) = 2 n (19) 23

25 Recursion-tree method Each node represents the cost of a single subproblem in a recursive call First, we sum the costs of the nodes in each level of the tree Then, we sum the costs of all of the levels 24

26 Recursion-tree method Can use to get a good guess which is then refined and verified using substitution method Best method (usually) for recurrences where a term like T (n/c) appears on the right hand side of the equality 25

27 Example 1 Consider the recurrence for the running time of Mergesort: T (n) = 2T (n/2) + n, T (1) = O(1) n n n/2 n/2 n n/4 n/4 n/4 n/4 n n/8 n/8 n/8 n/8 n/8 n/8 n/8 n/8 n 26

28 Example 1 We can see that each level of the tree sums to n Further the depth of the tree is log n (n/2 d = 1 implies that d = log n). Thus there are log n + 1 levels each of which sums to n Hence T (n) = Θ(n log n) 27

29 Example 2 Let s solve the recurrence T (n) = 3T (n/4) + n 2 Note: For simplicity, from now on, we ll assume that T (i) = Θ(1) for all small constants i. This will save us from writing the base cases each time. n^2 n^2 (n/4)^2 (n/4)^2 (n/4)^2 (3/16)n^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (n/16)^2 (3/16)^2*n^

30 Example 2 We can see that the i-th level of the tree sums to (3/16) i n 2. Further the depth of the tree is log 4 n (n/4 d = 1 implies that d = log 4 n) So we can see that T (n) = log 4 n i=0 (3/16)i n 2 29

31 Solution T (n) = log 4 n i=0 (3/16) i n 2 (20) < n 2 (3/16) i (21) = i=0 1 1 (3/16) n2 (22) = O(n 2 ) (23) 30

32 Master Theorem Divide and conquer algorithms often give us running-time recurrences of the form T (n) = a T (n/b) + f(n) (24) Where a and b are constants and f(n) is some other function. The so-called Master Method gives us a general method for solving such recurrences when f(n) is a simple polynomial. 31

33 Master Theorem Unfortunately, the Master Theorem doesn t work for all functions f(n) Further many useful recurrences don t look like T (n) However, the theorem allows for very fast solution of recurrences when it applies 32

34 Master Theorem Master Theorem is just a special case of the use of recursion trees Consider equation T (n) = a T (n/b) + f(n) We start by drawing a recursion tree 33

35 The Recursion Tree The root contains the value f(n) It has a children, each of which contains the value f(n/b) Each of these nodes has a children, containing the value f(n/b 2 ) In general, level i contains a i nodes with values f(n/b i ) Hence the sum of the nodes at the i-th level is a i f(n/b i ) 34

36 Details The tree stops when we get to the base case for the recurrence We ll assume T (1) = f(1) = Θ(1) is the base case Thus the depth of the tree is log b n and there are log b n + 1 levels 35

37 Recursion Tree Let T (n) be the sum of all values stored in all levels of the tree: T (n) = f(n)+a f(n/b)+a 2 f(n/b 2 )+ +a i f(n/b i )+ +a L f(n/b L ) Where L = log b n is the depth of the tree Since f(1) = Θ(1), the last term of this summation is Θ(a L ) = Θ(a log b n ) = Θ(n log b a ) 36

38 A Log Fact Aside It s not hard to see that a log b n = n log b a a log b n = n log b a a log b n = a log a n log b a (25) (26) log b n = log a n log b a (27) We get to the last eqn by taking log a of both sides The last eqn is true by our third basic log fact 37

39 Master Theorem We can now state the Master Theorem We will state it in a way slightly different from the book Note: The Master Method is just a short cut for the recursion tree method. It is less powerful than recursion trees. 38

40 Master Method The recurrence T (n) = at (n/b) + f(n) can be solved as follows: If a f(n/b) Kf(n) for some constant K < 1, then T (n) = Θ(f(n)). If a f(n/b) K f(n) for some constant K > 1, then T (n) = Θ(n log b a ). If a f(n/b) = f(n), then T (n) = Θ(f(n) log b n). 39

41 Proof If f(n) is a constant factor larger than a f(n/b), then the sum is a descending geometric series. The sum of any geometric series is a constant times its largest term. In this case, the largest term is the first term f(n). If f(n) is a constant factor smaller than a f(n/b), then the sum is an ascending geometric series. The sum of any geometric series is a constant times its largest term. In this case, this is the last term, which by our earlier argument is Θ(n log b a ). Finally, if a f(n/b) = f(n), then each of the L + 1 terms in the summation is equal to f(n). 40

42 Example T (n) = T (3n/4) + n If we write this as T (n) = at (n/b) + f(n), then a = 1,b = 4/3,f(n) = n Here a f(n/b) = 3n/4 is smaller than f(n) = n by a factor of 4/3, so T (n) = Θ(n) 41

43 Example Karatsuba s multiplication algorithm: T (n) = 3T (n/2) + n If we write this as T (n) = at (n/b) + f(n), then a = 3,b = 2,f(n) = n Here a f(n/b) = 3n/2 is bigger than f(n) = n by a factor of 3/2, so T (n) = Θ(n log 2 3 ) 42

44 Example Mergesort: T (n) = 2T (n/2) + n If we write this as T (n) = at (n/b) + f(n), then a = 2,b = 2,f(n) = n Here a f(n/b) = f(n), so T (n) = Θ(n log n) 43

45 Example T (n) = T (n/2) + n log n If we write this as T (n) = at (n/b) + f(n), then a = 1,b = 2,f(n) = n log n Here a f(n/b) = n/2 log n/2 is smaller than f(n) = n log n by a constant factor, so T (n) = Θ(n log n) 44

46 In-Class Exercise Consider the recurrence: T (n) = 4T (n/2) + n lg n Q: What is f(n) and a f(n/b)? Q: Which of the three cases does the recurrence fall under (when n is large)? Q: What is the solution to this recurrence? 45

47 In-Class Exercise Consider the recurrence: T (n) = 2T (n/4) + n lg n Q: What is f(n) and a f(n/b)? Q: Which of the three cases does the recurrence fall under (when n is large)? Q: What is the solution to this recurrence? 46

48 Take Away Recursion tree and Master method are good tools for solving many recurrences However these methods are limited (they can t help us get guesses for recurrences like f(n) = f(n 1) + f(n 2)) For info on how to solve these other more difficult recurrences, review the notes on annihilators on the class web page. 47

49 Intro to Annihilators Listen and Understand! That terminator is out there. It can t be bargained with, it can t be reasoned with! It doesn t feel pity, remorse, or fear. And it absolutely will not stop, ever, until you are dead! - The Terminator Suppose we are given a sequence of numbers A = a 0, a 1, a 2, This might be a sequence like the Fibonacci numbers I.e. A = a 0, a 1, a 2,... ) = (T (1), T (2), T (3), 48

50 Annihilator Operators We define three basic operations we can perform on this sequence: 1. Multiply the sequence by a constant: ca = ca 0, ca 1, ca 2, 2. Shift the sequence to the left: LA = a 1, a 2, a 3, 3. Add two sequences: if A = a 0, a 1, a 2, and B = b 0, b 1, b 2,, then A + B = a 0 + b 0, a 1 + b 1, a 2 + b 2, 49

51 Annihilator Description We first express our recurrence as a sequence T We use these three operators to annihilate T, i.e. make it all 0 s Key rule: can t multiply by the constant 0 We can then determine the solution to the recurrence from the sequence of operations performed to annihilate T 50

52 Example Consider the recurrence T (n) = 2T (n 1), T (0) = 1 If we solve for the first few terms of this sequence, we can see they are 2 0, 2 1, 2 2, 2 3, Thus this recurrence becomes the sequence: T = 2 0, 2 1, 2 2, 2 3, 51

53 Example (II) Let s annihilate T = 2 0, 2 1, 2 2, 2 3, Multiplying by a constant c = 2 gets: 2T = 2 2 0, 2 2 1, 2 2 2, 2 2 3, = 2 1, 2 2, 2 3, 2 4, Shifting one place to the left gets LT = 2 1, 2 2, 2 3, 2 4, Adding the sequence LT and 2T gives: LT 2T = , , , = 0, 0, 0, The annihilator of T is thus L 2 52

54 Distributive Property The distributive property holds for these three operators Thus can rewrite LT 2T as (L 2)T The operator (L 2) annihilates T (makes it the sequence of all 0 s) Thus (L 2) is called the annihilator of T 53

55 0, the Forbidden Annihilator Multiplication by 0 will annihilate any sequence Thus we disallow multiplication by 0 as an operation In particular, we disallow (c c) = 0 for any c as an annihilator Must always have at least one L operator in any annihilator! 54

56 Uniqueness An annihilator annihilates exactly one type of sequence In general, the annihilator L c annihilates any sequence of the form a 0 c n If we find the annihilator, we can find the type of sequence, and thus solve the recurrence We will need to use the base case for the recurrence to solve for the constant a 0 55

57 Example If we apply operator (L 3) to sequence T above, it fails to annihilate T (L 3)T = LT + ( 3)T = 2 1, 2 2, 2 3, , 3 2 1, 3 2 2, = (2 3) 2 0, (2 3) 2 1, (2 3) 2 2, = (2 3)T = T 56

58 Example (II) What does (L c) do to other sequences A = a 0 d n when d c?: (L c)a = (L c) a 0, a 0 d, a 0 d 2, a 0 d 3, = L a 0, a 0 d, a 0 d 2, a 0 d 3, c a 0, a 0 d, a 0 d 2, a 0 d 3, = a 0 d, a 0 d 2, a 0 d 3, ca 0, ca 0 d, ca 0 d 2, ca 0 d 3, = a 0 d ca 0, a 0 d 2 ca 0 d, a 0 d 3 ca 0 d 2, = (d c)a 0, (d c)a 0 d, (d c)a 0 d 2, = (d c) a 0, a 0 d, a 0 d 2, = (d c)a 57

59 Uniqueness The last example implies that an annihilator annihilates one type of sequence, but does not annihilate other types of sequences Thus Annihilators can help us classify sequences, and thereby solve recurrences 58

60 Lookup Table The annihilator L a annihilates any sequence of the form c 1 a n 59

61 Example First calculate the annihilator: Recurrence: T (n) = 4 T (n 1), T (0) = 2 Sequence: T = 2, 2 4, 2 4 2, 2 4 3, Calulate the annihilator: LT = 2 4, 2 4 2, 2 4 3, 2 4 4, 4T = 2 4, 2 4 2, 2 4 3, 2 4 4, Thus LT 4T = 0, 0, 0, And so L 4 is the annihilator 60

62 Example (II) Now use the annihilator to solve the recurrence Look up the annihilator in the Lookup Table It says: The annihilator L 4 annihilates any sequence of the form c 1 4 n Thus T (n) = c 1 4 n, but what is c 1? We know T (0) = 2, so T (0) = c = 2 and so c 1 = 2 Thus T (n) = 2 4 n 61

63 In Class Exercise Consider the recurrence T (n) = 3 T (n 1), T (0) = 3, Q1: Calculate T (0),T (1),T (2) and T (3) and write out the sequence T Q2: Calculate LT, and use it to compute the annihilator of T Q3: Look up this annihilator in the lookup table to get the general solution of the recurrence for T (n) Q4: Now use the base case T (0) = 3 to solve for the constants in the general solution 62

64 Remaining Outline Annihilators with Multiple Operators Annihilators for recurrences with non-homogeneous terms Transformations 63

65 Multiple Operators We can apply multiple operators to a sequence For example, we can multiply by the constant c and then by the constant d to get the operator cd We can also multiply by c and then shift left to get clt which is the same as LcT We can also shift the sequence twice to the left to get LLT which we ll write in shorthand as L 2 T 64

66 Multiple Operators We can string operators together to annihilate more complicated sequences Consider: T = , , , We know that (L 2) annihilates the powers of 2 while leaving the powers of 3 essentially untouched Similarly, (L 3) annihilates the powers of 3 while leaving the powers of 2 essentially untouched Thus if we apply both operators, we ll see that (L 2)(L 3) annihilates the sequence T 65

67 The Details Consider: T = a 0 + b 0, a 1 + b 1, a 2 + b 2, LT = a 1 + b 1, a 2 + b 2, a 3 + b 3, at = a 1 + a b 0, a 2 + a b 1, a 3 + a b 2, LT at = (b a)b 0, (b a)b 1, (b a)b 2, We know that (L a)t annihilates the a terms and multiplies the b terms by b a (a constant) Thus (L a)t = (b a)b 0, (b a)b 1, (b a)b 2, And so the sequence (L a)t is annihilated by (L b) Thus the annihilator of T is (L b)(l a) 66

68 Key Point In general, the annihilator (L a)(l b) (where a b) will anihilate only all sequences of the form c 1 a n + c 2 b n We will often multiply out (L a)(l b) to L 2 (a + b)l + ab Left as an exercise to show that (L a)(l b)t is the same as (L 2 (a + b)l + ab)t 67

69 Lookup Table The annihilator L a annihilates sequences of the form c 1 a n The annihilator (L a)(l b) (where a b) anihilates sequences of the form c 1 a n + c 2 b n 68

70 Fibonnaci Sequence We now know enough to solve the Fibonnaci sequence Recall the Fibonnaci recurrence is T (0) = 0, T (1) = 1, and T (n) = T (n 1) + T (n 2) Let T n be the n-th element in the sequence Then we ve got: T = T 0, T 1, T 2, T 3, (28) LT = T 1, T 2, T 3, T 4, (29) L 2 T = T 2, T 3, T 4, T 5, (30) Thus L 2 T LT T = 0, 0, 0, In other words, L 2 L 1 is an annihilator for T 69

71 Factoring L 2 L 1 is an annihilator that is not in our lookup table However, we can factor this annihilator (using the quadratic formula) to get something similar to what s in the lookup table L 2 L 1 = (L φ)(l ˆφ), where φ = and ˆφ =

72 Quadratic Formula Me fail English? That s Unpossible! - Ralph, the Simpsons High School Algebra Review: To factor something of the form ax 2 + bx + c, we use the Quadratic Formula: ax 2 + bx + c factors into (x φ)(x ˆφ), where: φ = b + b 2 4ac 2a ˆφ = b b 2 4ac 2a (31) (32) 71

73 Example To factor: L 2 L 1 Rewrite: 1 L 2 1 L 1, a = 1, b = 1, c = 1 From Quadratic Formula: φ = and ˆφ = So L 2 L 1 factors to (L φ)(l ˆφ) 72

74 Back to Fibonnaci Recall the Fibonnaci recurrence is T (0) = 0, T (1) = 1, and T (n) = T (n 1) + T (n 2) We ve shown the annihilator for T is (L φ)(l ˆφ), where φ = and ˆφ = If we look this up in the Lookup Table, we see that the sequence T must be of the form c 1 φ n + c 2ˆφ n All we have left to do is solve for the constants c 1 and c 2 Can use the base cases to solve for these 73

75 Finding the Constants We know T = c 1 φ n + c 2ˆφ n, where φ = and ˆφ = We know T (0) = c 1 + c 2 = 0 (33) T (1) = c 1 φ + c 2ˆφ = 1 (34) We ve got two equations and two unknowns Can solve to get c 1 = 1 and c 5 2 = 1 5, 74

76 The Punchline Recall Fibonnaci recurrence: T (0) = 0, T (1) = 1, and T (n) = T (n 1) + T (n 2) The final explicit formula for T (n) is thus: T (n) = 1 ( ) n ( ) n (Amazingly, T (n) is always an integer, in spite of all of the square roots in its formula.) 75

77 A Problem Our lookup table has a big gap: What does (L a)(l a) annihilate? It turns out it annihilates sequences such as na n 76

78 Example (L a) na n = (n + 1)a n+1 (a)na n = (n + 1)a n+1 na n+1 = (n + 1 n)a n+1 = a n+1 (L a) 2 na n = (L a) a n+1 = 0 77

79 Generalization It turns out that (L a) d annihilates sequences of the form p(n)a n where p(n) is any polynomial of degree d 1 Example: (L 1) 3 annihilates the sequence n 2 1 n = 1, 4, 9, 16, 25 since p(n) = n 2 is a polynomial of degree d 1 = 2 78

80 Lookup Table (L a) annihilates only all sequences of the form c 0 a n (L a)(l b) annihilates only all sequences of the form c 0 a n + c 1 b n (L a 0 )(L a 1 )... (L a k ) annihilates only sequences of the form c 0 a n 0 + c 1a n c ka n k, here a i a j, when i j (L a) 2 annihilates only sequences of the form (c 0 n + c 1 )a n (L a) k annihilates only sequences of the form p(n)a n, degree(p(n)) = k 1 79

81 Lookup Table (Final!) (L a 0 ) b 0(L a 1 ) b 1... (L a k ) b k annihilates only sequences of the form: p 1 (n)a n 0 + p 2(n)a n p k(n)a n k where p i (n) is a polynomial of degree b i 1 (and a i a j, when i j) 80

82 Examples Q: What does (L 3)(L 2)(L 1) annihilate? A: c 0 1 n + c 1 2 n + c 2 3 n Q: What does (L 3) 2 (L 2)(L 1) annihilate? A: c 0 1 n + c 1 2 n + (c 2 n + c 3 )3 n Q: What does (L 1) 4 annihilate? A: (c 0 n 3 + c 1 n 2 + c 2 n + c 3 )1 n Q: What does (L 1) 3 (L 2) 2 annihilate? A: (c 0 n 2 + c 1 n + c 2 )1 n + (c 3 n + c 4 )2 n 81

83 Annihilator Method Write down the annihilator for the recurrence Factor the annihilator Look up the factored annihilator in the Lookup Table to get general solution Solve for constants of the general solution by using initial conditions 82

84 Annihilator Method Write down the annihilator for the recurrence Factor the annihilator Look up the factored annihilator in the Lookup Table to get general solution Solve for constants of the general solution by using initial conditions 83

85 Lookup Table (L a 0 ) b 0(L a 1 ) b 1... (L a k ) b k annihilates only sequences of the form: p 0 (n)a n 0 + p 1(n)a n p k(n)a n k where p i (n) is a polynomial of degree b i 1 (and a i a j, when i j) 84

86 Examples Q: What does (L 3)(L 2)(L 1) annihilate? A: c 0 1 n + c 1 2 n + c 2 3 n Q: What does (L 3) 2 (L 2)(L 1) annihilate? A: c 0 1 n + c 1 2 n + (c 2 n + c 3 )3 n Q: What does (L 1) 4 annihilate? A: (c 0 n 3 + c 1 n 2 + c 2 n + c 3 )1 n Q: What does (L 1) 3 (L 2) 2 annihilate? A: (c 0 n 2 + c 1 n + c 2 )1 n + (c 3 n + c 4 )2 n 85

87 Example Consider the recurrence T (n) = 7T (n 1) 16T (n 2)+12T (n 3), T (0) = 1, T (1) = 5, T (2) = 17 Write down the annihilator: From the definition of the sequence, we can see that L 3 T 7L 2 T + 16LT 12T = 0, so the annihilator is L 3 7L L 12 Factor the annihilator: We can factor by hand or using a computer program to get L 3 7L 2 +16L 12 = (L 2) 2 (L 3) Look up to get general solution: The annihilator (L 2) 2 (L 3) annihilates sequences of the form (c 0 n + c 1 )2 n + c 2 3 n Solve for constants: T (0) = 1 = c 1 + c 2, T (1) = 5 = 2c 0 + 2c 1 + 3c 2, T (2) = 17 = 8c 0 + 4c 1 + 9c 2. We ve got three equations and three unknowns. Solving by hand, we get that c 0 = 1,c 1 = 0,c 2 = 1. Thus: T (n) = n2 n + 3 n 86

88 Example (II) Consider the recurrence T (n) = 2T (n 1) T (n 2), T (0) = 0, T (1) = 1 Write down the annihilator: From the definition of the sequence, we can see that L 2 T 2LT +T = 0, so the annihilator is L 2 2L + 1 Factor the annihilator: We can factor by hand or using the quadratic formula to get L 2 2L + 1 = (L 1) 2 Look up to get general solution: The annihilator (L 1) 2 annihilates sequences of the form (c 0 n + c 1 )1 n Solve for constants: T (0) = 0 = c 1, T (1) = 1 = c 0 + c 1, We ve got two equations and two unknowns. Solving by hand, we get that c 0 = 0,c 1 = 1. Thus: T (n) = n 87

89 At Home Exercise Consider the recurrence T (n) = 6T (n 1) 9T (n 2), T (0) = 1, T (1) = 6 Q1: What is the annihilator of this sequence? Q2: What is the factored version of the annihilator? Q3: What is the general solution for the recurrence? Q4: What are the constants in this general solution? (Note: You can check that your general solution works for T (2)) 88

90 Non-homogeneous terms Consider a recurrence of the form T (n) = T (n 1) + T (n 2) + k where k is some constant The terms in the equation involving T (i.e. T (n 1) and T (n 2)) are called the homogeneous terms The other terms (i.e.k) are called the non-homogeneous terms 89

91 Example In a height-balanced tree, the height of two subtrees of any node differ by at most one Let T (n) be the smallest number of nodes needed to obtain a height balanced binary tree of height n Q: What is a recurrence for T (n)? A: Divide this into smaller subproblems To get a height-balanced tree of height n with the smallest number of nodes, need one subtree of height n 1, and one of height n 2, plus a root node Thus T (n) = T (n 1) + T (n 2)

92 Example Let s solve this recurrence: T (n) = T (n 1) + T (n 2) + 1 (Let T n = T (n), and T = T n ) We know that (L 2 L 1) annihilates the homogeneous terms Let s apply it to the entire equation: (L 2 L 1) T n = L 2 T n L T n 1 T n = T n+2 T n+1 T n = T n+2 T n+1 T n = 1, 1, 1, 91

93 Example This is close to what we want but we still need to annihilate 1, 1, 1, It s easy to see that L 1 annihilates 1, 1, 1, Thus (L 2 L 1)(L 1) annihilates T (n) = T (n 1) + T (n 2) + 1 When we factor, we get (L φ)(l ˆφ)(L 1), where φ = and ˆφ =

94 Lookup Looking up (L φ)(l ˆφ)(L 1) in the table We get T (n) = c 1 φ n + c 2ˆφ n + c 3 1 n If we plug in the appropriate initial conditions, we can solve for these three constants We ll need to get equations for T (2) in addition to T (0) and T (1) 93

95 General Rule To find the annihilator for recurrences with non-homogeneous terms, do the following: Find the annihilator a 1 for the homogeneous part Find the annihilator a 2 for the non-homogeneous part The annihilator for the whole recurrence is then a 1 a 2 94

96 Another Example Consider T (n) = T (n 1) + T (n 2) + 2. The residue is 2, 2, 2, and The annihilator is still (L 2 L 1)(L 1), but the equation for T (2) changes! 95

97 Another Example Consider T (n) = T (n 1) + T (n 2) + 2 n. The residue is 1, 2, 4, 8, and The annihilator is now (L 2 L 1)(L 2). 96

98 Another Example Consider T (n) = T (n 1) + T (n 2) + n. The residue is 1, 2, 3, 4, The annihilator is now (L 2 L 1)(L 1) 2. 97

99 Another Example Consider T (n) = T (n 1) + T (n 2) + n 2. The residue is 1, 4, 9, 16, and The annihilator is (L 2 L 1)(L 1) 3. 98

100 Another Example Consider T (n) = T (n 1) + T (n 2) + n 2 2 n. The residue is 1 1, 4 4, 9 8, 16 16, and the The annihilator is (L 2 L 1)(L 1) 3 (L 2). 99

101 In Class Exercise Consider T (n) = 3 T (n 1) + 3 n Q1: What is the homogeneous part, and what annihilates it? Q2: What is the non-homogeneous part, and what annihilates it? Q3: What is the annihilator of T (n), and what is the general form of the recurrence? 100

102 Limitations Our method does not work on T (n) = T (n 1)+ n 1 or T (n) = T (n 1) + lg n The problem is that n 1 and lg n do not have annihilators. Our tool, as it stands, is limited. Key idea for strengthening it is transformations 101

103 Transformations Idea Consider the recurrence giving the run time of mergesort T (n) = 2T (n/2) + kn (for some constant k), T (1) = 1 How do we solve this? We have no technique for annihilating terms like T (n/2) However, we can transform the recurrence into one with which we can work 102

104 Transformation Let n = 2 i and rewrite T (n): T (2 0 ) = 1 and T (2 i ) = 2T ( 2i 2 ) + k2i = 2T (2 i 1 ) + k2 i Now define a new sequence t as follows: t(i) = T (2 i ) Then t(0) = 1, t(i) = 2t(i 1) + k2 i 103

105 Now Solve We ve got a new recurrence: t(0) = 1, t(i) = 2t(i 1) + k2 i We can easily find the annihilator for this recurrence (L 2) annihilates the homogeneous part, (L 2) annihilates the non-homogeneous part, So (L 2)(L 2) annihilates t(i) Thus t(i) = (c 1 i + c 2 )2 i 104

106 Reverse Transformation We ve got a solution for t(i) and we want to transform this into a solution for T (n) Recall that t(i) = T (2 i ) and 2 i = n t(i) = (c 1 i + c 2 )2 i (35) T (2 i ) = (c 1 i + c 2 )2 i (36) T (n) = (c 1 lg n + c 2 )n (37) = c 1 n lg n + c 2 n (38) = O(n lg n) (39) 105

107 Success! Let s recap what just happened: We could not find the annihilator of T (n) so: We did a transformation to a recurrence we could solve, t(i) (we let n = 2 i and t(i) = T (2 i )) We found the annihilator for t(i), and solved the recurrence for t(i) We reverse transformed the solution for t(i) back to a solution for T (n) 106

108 Another Example Consider the recurrence T (n) = 9T ( n 3 ) + kn, where T (1) = 1 and k is some constant Let n = 3 i and rewrite T (n): T (3 0 ) = 1 and T (3 i ) = 9T (3 i 1 ) + k3 i Now define a sequence t as follows t(i) = T (3 i ) Then t(0) = 1, t(i) = 9t(i 1) + k3 i 107

109 Now Solve t(0) = 1, t(i) = 9t(i 1) + k3 i This is annihilated by (L 9)(L 3) So t(i) is of the form t(i) = c 1 9 i + c 2 3 i 108

110 Reverse Transformation t(i) = c 1 9 i + c 2 3 i Recall: t(i) = T (3 i ) and 3 i = n t(i) = c 1 9 i + c 2 3 i T (3 i ) = c 1 9 i + c 2 3 i T (n) = c 1 (3 i ) 2 + c 2 3 i = c 1 n 2 + c 2 n = O(n 2 ) 109

111 In Class Exercise Consider the recurrence T (n) = 2T (n/4) + kn, where T (1) = 1, and k is some constant Q1: What is the transformed recurrence t(i)? How do we rewrite n and T (n) to get this sequence? Q2: What is the annihilator of t(i)? What is the solution for the recurrence t(i)? Q3: What is the solution for T (n)? (i.e. do the reverse transformation) 110

112 A Final Example Not always obvious what sort of transformation to do: Consider T (n) = 2T ( n) + log n Let n = 2 i and rewrite T (n): T (2 i ) = 2T (2 i/2 ) + i Define t(i) = T (2 i ): t(i) = 2t(i/2) + i 111

113 A Final Example This final recurrence is something we know how to solve! t(i) = O(i log i) The reverse transform gives: t(i) = O(i log i) (40) T (2 i ) = O(i log i) (41) T (n) = O(log n log log n) (42) 112

### Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4

Intro. to the Divide-and-Conquer Strategy via Merge Sort CMPSC 465 CLRS Sections 2.3, Intro. to and various parts of Chapter 4 I. Algorithm Design and Divide-and-Conquer There are various strategies we

### Induction. Margaret M. Fleck. 10 October These notes cover mathematical induction and recursive definition

Induction Margaret M. Fleck 10 October 011 These notes cover mathematical induction and recursive definition 1 Introduction to induction At the start of the term, we saw the following formula for computing

### Full and Complete Binary Trees

Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

### Mathematical Induction. Lecture 10-11

Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

### Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally

Recurrence Relations Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally modeled by recurrence relations. A recurrence relation is an equation which

### Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Recursion Slides by Christopher M Bourke Instructor: Berthe Y Choueiry Fall 007 Computer Science & Engineering 35 Introduction to Discrete Mathematics Sections 71-7 of Rosen cse35@cseunledu Recursive Algorithms

### 3. Mathematical Induction

3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

### MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

### Appendix: Solving Recurrences [Fa 10] Wil Wheaton: Embrace the dark side! Sheldon: That s not even from your franchise!

Change is certain. Peace is followed by disturbances; departure of evil men by their return. Such recurrences should not constitute occasions for sadness but realities for awareness, so that one may be

### Binary Search. Search for x in a sorted array A.

Divide and Conquer A general paradigm for algorithm design; inspired by emperors and colonizers. Three-step process: 1. Divide the problem into smaller problems. 2. Conquer by solving these problems. 3.

### 3.6. Partial Fractions. Introduction. Prerequisites. Learning Outcomes

Partial Fractions 3.6 Introduction It is often helpful to break down a complicated algebraic fraction into a sum of simpler fractions. For 4x + 7 example it can be shown that x 2 + 3x + 2 has the same

### From Last Time: Remove (Delete) Operation

CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From

### Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

### Divide And Conquer Algorithms

CSE341T/CSE549T 09/10/2014 Lecture 5 Divide And Conquer Algorithms Recall in last lecture, we looked at one way of parallelizing matrix multiplication. At the end of the lecture, we saw the reduce SUM

### SYSTEMS OF EQUATIONS

SYSTEMS OF EQUATIONS 1. Examples of systems of equations Here are some examples of systems of equations. Each system has a number of equations and a number (not necessarily the same) of variables for which

### The Method of Partial Fractions Math 121 Calculus II Spring 2015

Rational functions. as The Method of Partial Fractions Math 11 Calculus II Spring 015 Recall that a rational function is a quotient of two polynomials such f(x) g(x) = 3x5 + x 3 + 16x x 60. The method

### Vieta s Formulas and the Identity Theorem

Vieta s Formulas and the Identity Theorem This worksheet will work through the material from our class on 3/21/2013 with some examples that should help you with the homework The topic of our discussion

### Format of Divide-and-Conquer algorithms:

CS 360: Data Structures and Algorithms Divide-and-Conquer (part 1) Format of Divide-and-Conquer algorithms: Divide: Split the array or list into smaller pieces Conquer: Solve the same problem recursively

### CS473 - Algorithms I

CS473 - Algorithms I Lecture 4 The Divide-and-Conquer Design Paradigm View in slide-show mode 1 Reminder: Merge Sort Input array A sort this half sort this half Divide Conquer merge two sorted halves Combine

### CS 102: SOLUTIONS TO DIVIDE AND CONQUER ALGORITHMS (ASSGN 4)

CS 10: SOLUTIONS TO DIVIDE AND CONQUER ALGORITHMS (ASSGN 4) Problem 1. a. Consider the modified binary search algorithm so that it splits the input not into two sets of almost-equal sizes, but into three

### WRITING PROOFS. Christopher Heil Georgia Institute of Technology

WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this

### Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

### Partial Fractions. Combining fractions over a common denominator is a familiar operation from algebra:

Partial Fractions Combining fractions over a common denominator is a familiar operation from algebra: From the standpoint of integration, the left side of Equation 1 would be much easier to work with than

### Factoring Polynomials and Solving Quadratic Equations

Factoring Polynomials and Solving Quadratic Equations Math Tutorial Lab Special Topic Factoring Factoring Binomials Remember that a binomial is just a polynomial with two terms. Some examples include 2x+3

### Sample Induction Proofs

Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given

### Polynomials and Vieta s Formulas

Polynomials and Vieta s Formulas Misha Lavrov ARML Practice 2/9/2014 Review problems 1 If a 0 = 0 and a n = 3a n 1 + 2, find a 100. 2 If b 0 = 0 and b n = n 2 b n 1, find b 100. Review problems 1 If a

### Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Quiz 1 Quiz 1 Do not open this quiz booklet until you are directed

### Notes on Determinant

ENGG2012B Advanced Engineering Mathematics Notes on Determinant Lecturer: Kenneth Shum Lecture 9-18/02/2013 The determinant of a system of linear equations determines whether the solution is unique, without

### CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

### SECTION 10-2 Mathematical Induction

73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

### THE GOLDEN RATIO AND THE FIBONACCI SEQUENCE

/ 24 THE GOLDEN RATIO AND THE FIBONACCI SEQUENCE Todd Cochrane Everything is Golden 2 / 24 Golden Ratio Golden Proportion Golden Relation Golden Rectangle Golden Spiral Golden Angle Geometric Growth, (Exponential

### PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include 2 + 5.

PUTNAM TRAINING POLYNOMIALS (Last updated: November 17, 2015) Remark. This is a list of exercises on polynomials. Miguel A. Lerma Exercises 1. Find a polynomial with integral coefficients whose zeros include

### x if x 0, x if x < 0.

Chapter 3 Sequences In this chapter, we discuss sequences. We say what it means for a sequence to converge, and define the limit of a convergent sequence. We begin with some preliminary results about the

### CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential

### Math 55: Discrete Mathematics

Math 55: Discrete Mathematics UC Berkeley, Fall 2011 Homework # 5, due Wednesday, February 22 5.1.4 Let P (n) be the statement that 1 3 + 2 3 + + n 3 = (n(n + 1)/2) 2 for the positive integer n. a) What

### is identically equal to x 2 +3x +2

Partial fractions 3.6 Introduction It is often helpful to break down a complicated algebraic fraction into a sum of simpler fractions. 4x+7 For example it can be shown that has the same value as 1 + 3

### Notes: Chapter 2 Section 2.2: Proof by Induction

Notes: Chapter 2 Section 2.2: Proof by Induction Basic Induction. To prove: n, a W, n a, S n. (1) Prove the base case - S a. (2) Let k a and prove that S k S k+1 Example 1. n N, n i = n(n+1) 2. Example

### Lecture 3: Linear Programming Relaxations and Rounding

Lecture 3: Linear Programming Relaxations and Rounding 1 Approximation Algorithms and Linear Relaxations For the time being, suppose we have a minimization problem. Many times, the problem at hand can

### The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

### Data Structures and Algorithms

Data Structures and Algorithms CS245-2016S-06 Binary Search Trees David Galles Department of Computer Science University of San Francisco 06-0: Ordered List ADT Operations: Insert an element in the list

### The last three chapters introduced three major proof techniques: direct,

CHAPTER 7 Proving Non-Conditional Statements The last three chapters introduced three major proof techniques: direct, contrapositive and contradiction. These three techniques are used to prove statements

### Elementary Number Theory We begin with a bit of elementary number theory, which is concerned

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

### Section 6-2 Mathematical Induction

6- Mathematical Induction 457 In calculus, it can be shown that e x k0 x k k! x x x3!! 3!... xn n! where the larger n is, the better the approximation. Problems 6 and 6 refer to this series. Note that

### Arithmetic Operations. The real numbers have the following properties: In particular, putting a 1 in the Distributive Law, we get

Review of Algebra REVIEW OF ALGEBRA Review of Algebra Here we review the basic rules and procedures of algebra that you need to know in order to be successful in calculus. Arithmetic Operations The real

### Ordered Lists and Binary Trees

Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:

### An Interesting Way to Combine Numbers

An Interesting Way to Combine Numbers Joshua Zucker and Tom Davis November 28, 2007 Abstract This exercise can be used for middle school students and older. The original problem seems almost impossibly

### SYSTEMS OF PYTHAGOREAN TRIPLES. Acknowledgements. I would like to thank Professor Laura Schueller for advising and guiding me

SYSTEMS OF PYTHAGOREAN TRIPLES CHRISTOPHER TOBIN-CAMPBELL Abstract. This paper explores systems of Pythagorean triples. It describes the generating formulas for primitive Pythagorean triples, determines

### CMPS 102 Solutions to Homework 1

CMPS 0 Solutions to Homework Lindsay Brown, lbrown@soe.ucsc.edu September 9, 005 Problem..- p. 3 For inputs of size n insertion sort runs in 8n steps, while merge sort runs in 64n lg n steps. For which

Section 5.4 The Quadratic Formula 481 5.4 The Quadratic Formula Consider the general quadratic function f(x) = ax + bx + c. In the previous section, we learned that we can find the zeros of this function

### 26 Integers: Multiplication, Division, and Order

26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue

### Algorithms. Margaret M. Fleck. 18 October 2010

Algorithms Margaret M. Fleck 18 October 2010 These notes cover how to analyze the running time of algorithms (sections 3.1, 3.3, 4.4, and 7.1 of Rosen). 1 Introduction The main reason for studying big-o

### Quotient Rings and Field Extensions

Chapter 5 Quotient Rings and Field Extensions In this chapter we describe a method for producing field extension of a given field. If F is a field, then a field extension is a field K that contains F.

### 3.2. Solving quadratic equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

Solving quadratic equations 3.2 Introduction A quadratic equation is one which can be written in the form ax 2 + bx + c = 0 where a, b and c are numbers and x is the unknown whose value(s) we wish to find.

### 6.3 Conditional Probability and Independence

222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

### Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

Binary Search Trees Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 27 1 Properties of Binary Search Trees 2 Basic BST operations The worst-case time complexity of BST operations

### Math 115 Spring 2011 Written Homework 5 Solutions

. Evaluate each series. a) 4 7 0... 55 Math 5 Spring 0 Written Homework 5 Solutions Solution: We note that the associated sequence, 4, 7, 0,..., 55 appears to be an arithmetic sequence. If the sequence

### 1 2-3 Trees: The Basics

CS10: Data Structures and Object-Oriented Design (Fall 2013) November 1, 2013: 2-3 Trees: Inserting and Deleting Scribes: CS 10 Teaching Team Lecture Summary In this class, we investigated 2-3 Trees in

### 8.1 Makespan Scheduling

600.469 / 600.669 Approximation Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programing: Min-Makespan and Bin Packing Date: 2/19/15 Scribe: Gabriel Kaptchuk 8.1 Makespan Scheduling Consider an instance

### Divide-and-Conquer Algorithms Part Four

Divide-and-Conquer Algorithms Part Four Announcements Problem Set 2 due right now. Can submit by Monday at 2:15PM using one late period. Problem Set 3 out, due July 22. Play around with divide-and-conquer

### PRINCIPLES OF PROBLEM SOLVING

PRINCIPLES OF PROBLEM SOLVING There are no hard and fast rules that will ensure success in solving problems. However, it is possible to outline some general steps in the problem-solving process and to

### Taylor Polynomials and Taylor Series Math 126

Taylor Polynomials and Taylor Series Math 26 In many problems in science and engineering we have a function f(x) which is too complicated to answer the questions we d like to ask. In this chapter, we will

9.3 Solving Quadratic Equations by Using the Quadratic Formula 9.3 OBJECTIVES 1. Solve a quadratic equation by using the quadratic formula 2. Determine the nature of the solutions of a quadratic equation

### a) x 2 8x = 25 x 2 8x + 16 = (x 4) 2 = 41 x = 4 ± 41 x + 1 = ± 6 e) x 2 = 5 c) 2x 2 + 2x 7 = 0 2x 2 + 2x = 7 x 2 + x = 7 2

Solving Quadratic Equations By Square Root Method Solving Quadratic Equations By Completing The Square Consider the equation x = a, which we now solve: x = a x a = 0 (x a)(x + a) = 0 x a = 0 x + a = 0

### Pythagorean Triples. Chapter 2. a 2 + b 2 = c 2

Chapter Pythagorean Triples The Pythagorean Theorem, that beloved formula of all high school geometry students, says that the sum of the squares of the sides of a right triangle equals the square of the

### Fractions and Decimals

Fractions and Decimals Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles December 1, 2005 1 Introduction If you divide 1 by 81, you will find that 1/81 =.012345679012345679... The first

### Answer Key for California State Standards: Algebra I

Algebra I: Symbolic reasoning and calculations with symbols are central in algebra. Through the study of algebra, a student develops an understanding of the symbolic language of mathematics and the sciences.

### Algebra Tiles Activity 1: Adding Integers

Algebra Tiles Activity 1: Adding Integers NY Standards: 7/8.PS.6,7; 7/8.CN.1; 7/8.R.1; 7.N.13 We are going to use positive (yellow) and negative (red) tiles to discover the rules for adding and subtracting

### FACTORING QUADRATICS 8.1.1 and 8.1.2

FACTORING QUADRATICS 8.1.1 and 8.1.2 Chapter 8 introduces students to quadratic equations. These equations can be written in the form of y = ax 2 + bx + c and, when graphed, produce a curve called a parabola.

### Equations and Inequalities

Rational Equations Overview of Objectives, students should be able to: 1. Solve rational equations with variables in the denominators.. Recognize identities, conditional equations, and inconsistent equations.

### 3.3. Solving Polynomial Equations. Introduction. Prerequisites. Learning Outcomes

Solving Polynomial Equations 3.3 Introduction Linear and quadratic equations, dealt within Sections 3.1 and 3.2, are members of a class of equations, called polynomial equations. These have the general

### Problem Set 7 - Fall 2008 Due Tuesday, Oct. 28 at 1:00

18.781 Problem Set 7 - Fall 2008 Due Tuesday, Oct. 28 at 1:00 Throughout this assignment, f(x) always denotes a polynomial with integer coefficients. 1. (a) Show that e 32 (3) = 8, and write down a list

### We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: 9081 + 900b + 90c = 9001 + 100c + 10b

In this session, we ll learn how to solve problems related to place value. This is one of the fundamental concepts in arithmetic, something every elementary and middle school mathematics teacher should

### The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

### Today s Outline. Exercise. Binary Search Analysis. Linear Search Analysis. Asymptotic Analysis. Analyzing Code. Announcements. Asymptotic Analysis

Today s Outline Announcements Assignment #1 due Thurs, Oct 7 at 11:45pm Asymptotic Analysis Asymptotic Analysis CSE 7 Data Structures & Algorithms Ruth Anderson Autumn 2010 Exercise Analyzing Code bool

### Discrete Mathematics: Homework 7 solution. Due: 2011.6.03

EE 2060 Discrete Mathematics spring 2011 Discrete Mathematics: Homework 7 solution Due: 2011.6.03 1. Let a n = 2 n + 5 3 n for n = 0, 1, 2,... (a) (2%) Find a 0, a 1, a 2, a 3 and a 4. (b) (2%) Show that

### 1 Lecture: Integration of rational functions by decomposition

Lecture: Integration of rational functions by decomposition into partial fractions Recognize and integrate basic rational functions, except when the denominator is a power of an irreducible quadratic.

### MATH 10034 Fundamental Mathematics IV

MATH 0034 Fundamental Mathematics IV http://www.math.kent.edu/ebooks/0034/funmath4.pdf Department of Mathematical Sciences Kent State University January 2, 2009 ii Contents To the Instructor v Polynomials.

### Continued Fractions. Darren C. Collins

Continued Fractions Darren C Collins Abstract In this paper, we discuss continued fractions First, we discuss the definition and notation Second, we discuss the development of the subject throughout history

### Core Maths C1. Revision Notes

Core Maths C Revision Notes November 0 Core Maths C Algebra... Indices... Rules of indices... Surds... 4 Simplifying surds... 4 Rationalising the denominator... 4 Quadratic functions... 4 Completing the

### Mathematical Induction

Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

### Partial Fractions. (x 1)(x 2 + 1)

Partial Fractions Adding rational functions involves finding a common denominator, rewriting each fraction so that it has that denominator, then adding. For example, 3x x 1 3x(x 1) (x + 1)(x 1) + 1(x +

### 1 Review of complex numbers

1 Review of complex numbers 1.1 Complex numbers: algebra The set C of complex numbers is formed by adding a square root i of 1 to the set of real numbers: i = 1. Every complex number can be written uniquely

### Merge Sort. 2004 Goodrich, Tamassia. Merge Sort 1

Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort 1 Divide-and-Conquer Divide-and conquer is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets

### Balanced Binary Search Tree

AVL Trees / Slide 1 Balanced Binary Search Tree Worst case height of binary search tree: N-1 Insertion, deletion can be O(N) in the worst case We want a tree with small height Height of a binary tree with

### a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

### God created the integers and the rest is the work of man. (Leopold Kronecker, in an after-dinner speech at a conference, Berlin, 1886)

Chapter 2 Numbers God created the integers and the rest is the work of man. (Leopold Kronecker, in an after-dinner speech at a conference, Berlin, 1886) God created the integers and the rest is the work

### SMT 2014 Algebra Test Solutions February 15, 2014

1. Alice and Bob are painting a house. If Alice and Bob do not take any breaks, they will finish painting the house in 20 hours. If, however, Bob stops painting once the house is half-finished, then the

### a 1 x + a 0 =0. (3) ax 2 + bx + c =0. (4)

ROOTS OF POLYNOMIAL EQUATIONS In this unit we discuss polynomial equations. A polynomial in x of degree n, where n 0 is an integer, is an expression of the form P n (x) =a n x n + a n 1 x n 1 + + a 1 x

### Appendix F: Mathematical Induction

Appendix F: Mathematical Induction Introduction In this appendix, you will study a form of mathematical proof called mathematical induction. To see the logical need for mathematical induction, take another

### CLASS 3, GIVEN ON 9/27/2010, FOR MATH 25, FALL 2010

CLASS 3, GIVEN ON 9/27/2010, FOR MATH 25, FALL 2010 1. Greatest common divisor Suppose a, b are two integers. If another integer d satisfies d a, d b, we call d a common divisor of a, b. Notice that as

### Week 7: Divide and Conquer

Agenda: Divide and Conquer technique Multiplication of large integers Exponentiation Matrix multiplication 1 2- Divide and Conquer : To solve a problem we can break it into smaller subproblems, solve each

### ARITHMETICAL FUNCTIONS II: CONVOLUTION AND INVERSION

ARITHMETICAL FUNCTIONS II: CONVOLUTION AND INVERSION PETE L. CLARK 1. Sums over divisors, convolution and Möbius Inversion The proof of the multiplicativity of the functions σ k, easy though it was, actually

### Math 313 Lecture #10 2.2: The Inverse of a Matrix

Math 1 Lecture #10 2.2: The Inverse of a Matrix Matrix algebra provides tools for creating many useful formulas just like real number algebra does. For example, a real number a is invertible if there is

### Homework 5 Solutions

Homework 5 Solutions 4.2: 2: a. 321 = 256 + 64 + 1 = (01000001) 2 b. 1023 = 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = (1111111111) 2. Note that this is 1 less than the next power of 2, 1024, which

### Second Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients. y + p(t) y + q(t) y = g(t), g(t) 0.

Second Order Linear Nonhomogeneous Differential Equations; Method of Undetermined Coefficients We will now turn our attention to nonhomogeneous second order linear equations, equations with the standard

### is identically equal to x 2 +3x +2

Partial fractions.6 Introduction It is often helpful to break down a complicated algebraic fraction into a sum of simpler fractions. 4x+7 For example it can be shown that has the same value as + for any

### MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS Systems of Equations and Matrices Representation of a linear system The general system of m equations in n unknowns can be written a x + a 2 x 2 + + a n x n b a

### Sequences and Series

Sequences and Series Consider the following sum: 2 + 4 + 8 + 6 + + 2 i + The dots at the end indicate that the sum goes on forever. Does this make sense? Can we assign a numerical value to an infinite