Compare the growth rate of functions

Size: px
Start display at page:

Download "Compare the growth rate of functions"

Transcription

1 Compare the growth rate of functions We have two algorithms A 1 and A 2 for solving the same problem, with runtime functions T 1 (n) and T 2 (n), respectively. Which algorithm is more efficient? We compare the growth rate of T 1 (n) and T 2 (n). If T 1 (n) = Θ(T 2 (n)), then the efficiency of the two algorithms are about the same (when n is large). If T 1 (n) = o(t 2 (n)), then the efficiency of the algorithm A 1 will be better than that of algorithm A 2 (when n is large). By using the definitions, we can directly show whether T 1 (n) = O(T 2 (n)), or T 1 (n) = Ω(T 2 (n)). However, it is not easy to prove the relationship of two functions in this way. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 2 / 36

2 Limit Test Limit Test is a powerful method for comparing functions. Limit Test Let T 1 (n) and T 2 (n) be two functions. Let c = lim n T 1(n) T 2(n). 1 If c is a constant > 0, then T 1 (n) = Θ(T 2 (n)). 2 If c = 0, then T 1 (n) = o(t 2 (n)). 3 If c =, then T 1 (n) = ω(t 2 (n)). 4 If c does not exists (or if we do not know how to compute c), the limit test fails. T Proof of (1): c = lim 1(n) n T means: ɛ > 0, there exists n 2(n) 0 0 such that for any n n 0 : T1(n) T c 2(n) ɛ; or equivalently: c ɛ T 1(n) T 2(n) c + ɛ. Let ɛ = c/2 and let c 1 = c ɛ = c/2 and c 2 = c + ɛ = 3c/2, we have c 1 T 2 (n) T 1 (n) c 2 T 2 (n) for all n n 0. Thus T 1 (n) = Θ(T 2 (n)) by definition. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 4 / 36

3 Example Example 1 T 1 (n) = 10n n 60, T 2 (n) = n 2 T 1 (n) lim n T 2 (n) = lim 10n n 60 n n 2 = lim (10+15 n n 60 ) = = 10 n2 Since 10 is a constant > 0, we have T 1 (n) = Θ(T 2 (n)) = Θ(n 2 ) by the statement 1 of Limit Test (as expected). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 5 / 36

4 Log function The log functions are very useful in algorithm analysis. lg = log 2 n log n = log 10 n ln n = log e n (ln n is the log function with the natural base e = ). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 6 / 36

5 Log base change formula Log base change formula For any 1 < a, b, log b n = log a n log a b = log b a log a n. Proof: Let k = log b n. By definition: n = b k. Take log a on both sides: log a n = log a (b k ) = k log a b This implies: log b n = k = log a n log a b. Let n = a in this formula and note 1 = log a a: log b a = log a a log a b = 1 log a b This proves the second part of the formula. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 7 / 36

6 L Hospital Rule L Hospital Rule If lim n f (n) = 0 and lim n g(n) = 0, then f (n) lim n g(n) = lim f (n) n g (n) If lim n f (n) = and lim n g(n) =, then f (n) lim n g(n) = lim f (n) n g (n) c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 9 / 36

7 Example Example 2 T 1 (n) = n 2 + 6, T 2 (n) = n lg n. (Recall: lg n = log 2 n.) T lim 1 (n) n T 2 (n) = lim n n2 +6 n lg n = lim n+ 6 n n lg n 1 6 n = lim 2 n 1 (by L Hospital Rule) ln 2 n = ln 2 lim n (n 6 n ) = ln 2( 0) = By Limit Test, we have n = ω(n lg n). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 10 / 36

8 Example Example 3 T 1 (n) = (ln n) k, T 2 (n) = n ɛ, where k > 0 is any (large) constant and ɛ > 0 is any (small) constant. (Recall: ln n = log e n.) T lim 1 (n) n T 2 (n) = lim (ln n)k n n ɛ k(ln n) = lim k 1 (1/n) n = k ɛ lim n = k(k 1) ɛ 2 ɛn (ɛ 1) (ln n)k 1 n ɛ lim n (ln n) k 2 n ɛ... = k(k 1) 2 1 ɛ k lim n 1 n ɛ = 0 (use L Hospital Rule) (use L Hospital Rule again and simplify) (use L Hospital Rule k times) So by Limit Test, (ln n) k = o(n ɛ ) for any k and ɛ. For example, take k = 100 and ɛ = 0.01, we have (ln n) 100 = o(n 0.01 ). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 11 / 36

9 Example Example 4 T 1 (n) = n k, T 2 (n) = a n, where k > 0 is any (large) constant and a > 1 is any constant bigger than 1. lim n T 1 (n) T 2 (n) = lim n nk a n = lim n k n k 1 ln a a n = k = k(k 1) 2 1 (ln a) k lim n n 0 a n ln a lim n nk 1 a n = k(k 1) 2 1 (ln a) k lim n 1 a n = 0 (using L Hospital Rule) ( using L Hospital Rule k times) So by Limit Test, n k = o(a n ) for any k > 0 and a > 1. For example, take k = 1000 and a = 1.001, we have n 1000 = o((1.001) n ). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 12 / 36

10 Example Example 5 T 1 (n) = log a n, T 2 (n) = log b n, where a > 1 and b > 1 are any two constants bigger than 1. By the Log Base Change Formula: log b n = log b a log a n T Thus: lim 1 (n) n T 2 (n) = lim n log a n log b n = lim n log a n log b a log a n = 1 log b a Since 1 log b a > 0 is a constant, we have log a n = Θ(log b n) by Limit Test. So: the growth rates of the log functions are the same for any base > 1. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 13 / 36

11 Example Example 6 T 1 (n) = a n, T 2 (n) = b n, where 1 < a < b are any two constants. We have: lim n T 1 (n) T 2 (n) = lim n an b n = lim n ( a b )n = 0. Thus: a n = o(b n ) (for any 1 < a < b) by Limit Test. The list of common functions: The following list shows the functions commonly used in algorithm analysis, in the order of increasing growth rate (a, b, c, d, k, ɛ are positive constants, ɛ < 1, k > 1, d > 1 and a < b): c, log d n, (log d n) k, n ɛ, n, n k, a n, b n, n!, n n in the sense that if f (n) and g(n) are any two consecutive functions in the list, we have f (n) = o(g(n)) c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 14 / 36

12 Examples Example 7 T 1 (n) = n! and T 2 (n) = a n (a > 1) lim n a n n! =? L Hospital Rule doesn t help: We don t know how to take derivative of n! n! = a 1 a 2 a a 2 a 2 a + 1 a n }{{}}{{} 2 a terms (n 2 a ) terms a n The first part is a constant c > 0. In the second part, each term < 1/2. So: a n 0 lim n n! c lim (1 n 2 )(n 2 a ) = 0 By Limit Test: a n = o(n!). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 15 / 36

13 Stirling Formula Stirling Formula ( n ) n 1 ( 2πn e 12n+1 n ) n 1 n! 2πn e 12n e e or: n! = ( n ) ( ( )) n 1 2πn 1 + Θ e n When n = 10; n! = ( 2πn n ) n e = , 99% accurate. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 17 / 36

14 Examples Example 7 (another solution) T 1 (n) = n! and T 2 (n) = a n (a > 1) n! lim n a n lim ( n ) n ( n ) n 2πn = lim 2πn lim n ae n n ae The first limit is. The second limit goes to. So it s also. Thus n! lim n a = and n! = ω(a n ) by limit test. n Example 8 T 1 (n) = n n and T 2 (n) = n! By using similar method as in Example 7, we can show: n! = o(n n ) c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 18 / 36

15 Summations Consider the following simple program: 1: for i = 1 to n do 2: the loop body takes Θ(i k ) time 3: end for What s the runtime of this program? It should be: T(n) = n n Θ(i k ) = c i k (for some constant c) i=1 i=1 Thus, it is important to know the sum of the form n i=1 ik. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 20 / 36

16 Summation formulas n i 1 = n = i=1 n i 2 = n 2 = i=1 i=1 n(n + 1) 2 = Θ(n 2 ) (1) n(n + 1)(2n + 1) 6 = Θ(n 3 ) (2) n i 3 = n 3 = n2 (n + 1) 2 = Θ(n 4 ) (3) 4 In general, for any k > 0, the following is true. n i k = Θ(n k+1 ) (4) i=1 c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 21 / 36

17 Summations: By using these formulas, we can compute the runtime of nested loops. Example for i = 1 to n do for j = i to n do for k = i to j do (... loop body takes Θ(1) time.) end for end for end for Since the inner loop body takes Θ(1) time, we only need to count the number D(n) of the inner loop iterations. Then T(n) = D(n) Θ(1) = Θ(D(n)). D(n) = n n j i=1 j=i k=i 1 = n n i=1 j=i (j i + 1) c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 22 / 36

18 Calculate D(n) To calculate the second sum, let t = j i + 1. When j = i, t = 1. When j = n, t = n i + 1. Thus n (j i + 1) = j=i n i+1 t=1 t = (n i + 1) = (n i + 2)(n i + 1) 2 Next we calculate: n (n i+2)(n i+1) i=1 2. Let s = n i + 1. When i = 1, s = n. When i = n, s = 1. Thus: = n s=1 (s+1)s 2 = 1 2 { n s=1 s2 + n s=1 s} = 1 2 { n(n+1)(2n+1) 6 + n(n+1) 2 } = Θ(n 3 ) c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 23 / 36

19 More Summations: The following summation formulas are useful. 1 a n n+1 a i = 1 + a + a a n 1 a = Θ(1) if 0 < a < 1 = n + 1 = Θ(n) if a = 1 i=0 a n+1 1 a 1 = Θ(a n ) if 1 < a (5) n i=0 ai is called geometric series. H(n) = 1 + 1/2 + 1/ /n = n i=1 1 i = Θ(ln n) (6) H(n) is called Harmonic series. How to compute H(n)? c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 24 / 36

20 Integration Method Integration Method Let f (x) be an increasing function. Then for any a b: b a 1 f (x)dx b f (i) i=a b+1 a f (x)dx In the Fig, = the area of the staircase region. The first = the area of the shaded region. Since f (x) is increasing, the first holds. f(b) f(b 1) f(x) f(a) x a 1 a a+1 b 1 b c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 26 / 36

21 Integration Method In the Fig, is the area of the staircase region. The second is the area of the shaded region. Since f (x) is increasing, the second holds. f(b+1) f(b) f(x) f(a) a a+1 b b+1 x Similarly: Let f (x) be a decreasing function. Then for any a b: b a 1 f (x)dx b f (i) i=a b+1 a f (x)dx c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 27 / 36

22 Example Example For any k > 0, f (x) = x k is an increasing function. Let a = 1 and b = n. n 0 x k dx n i k i=1 n+1 1 x k dx n 0 xk dx = 1 k+1 xk+1 x=n x=0 = nk+1 k+1 ; n+1 1 x k dx = 1 k+1 xk+1 x=n+1 x=1 = (n+1)k+1 1 k+1 Thus: n k+1 k + 1 n i=1 i k (n + 1)k+1 1 k + 1 By limit test, both lower and upper bounds = Θ(n k+1 ). Thus n i=1 ik = Θ(n k+1 ). c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 28 / 36

23 Example f (x) = 1 x is a decreasing function. Let a = 1 and b = n. n 0 n 0 dx x n i=1 1 n+1 i dx 1 x dx x = ln x n 0 = ln n ( ) =. This doesn t work! Try a = 2 and b = n: n 1 dx x n i=2 1 n+1 i dx 2 x This gives: (ln n ln 1) n i=2 1 i (ln(n + 1) ln 2). Note ln 1 = 0. Add 1 to the above: 1 + ln n n i=1 1 i (ln(n + 1) ln 2 + 1). By limit test, both lower and upper bounds = Θ(ln n). So H(n) = n i=1 1 i = Θ(ln n) Note: lim n (ln n n i=1 1 i ) = c, where c = is Euler constant. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 29 / 36

24 Solving Linear Recursive Equations Fibonacci number Fib 0 = 0, Fib 1 = 1,..., Fib n+2 = Fib n+1 + Fib n How to compute Fib n directly from n? ( Fib n = ) n ( ) n 5 2 1± 5 2 are the two roots of the equation: x 2 = x + 1. Since 1 5 < 1, the second term 0. So Fib n 1 2 (α = = is called the golden ratio.) For n = 8, Fib 8 = 21 where 1 5 α n = How to find such formula? ( c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 31 / 36 ) n.

25 Linear recursive sequences Linear recursive sequences A sequence {f 0, f 1,..., f n...} is called a linear recursive sequence of order k if it is defined as follows: f 0, f 1,..., f k 1 are given. For all n 0, f n+k = c k 1 f n+k 1 + c k 2 f n+k c 1 f n+1 + c 0 f n where c k 1, c k 2,... c 0 are fixed constants. Example 1: {Fib n } is a linear recursive sequence of order 2 where c 1 = 1 and c 0 = 1. Example 2: f 0 = 1, f 1 = 2, f 2 = 4 and for all n 0, f n+3 = 3f n+1 2f n Then {f n } is a linear recursive sequence of order 3 where c 2 = 0, c 1 = 3 and c 0 = 2. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 32 / 36

26 Solving linear recursive sequences The characteristic equation of the linear recursive seq is: x k = c k 1 x k 1 + c k 2 x k c 1 x 1 + c 0 Solve this equation for x. Let α 1,..., α k be the roots. Assuming all roots are distinct. Then the solution of f n has the form f n = a 1 (α 1 ) n + a 2 (α 2 ) n + + a k (α k ) n for some constants a 1, a 2,..., a k. Plug in the initial values f 0, f 1,..., f k 1, we get k equations. Solve them to find a 1, a 2,..., a k. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 33 / 36

27 Example Fibonacci number F 0 = 0, F 1 = 1 and F n+2 = F n+1 + F n The characteristic equation is: x 2 = x + 1. The roots are: α 1 = and α 2 = The solution has the form: F n = a 1 (α 1 ) n + a 2 (α 2 ) n Plug in initial value F 0 = 0 and F 1 = 1: 0 = F 0 = a 1 α a 2α 0 2 = a 1 + a 2 1 = F 1 = a 1 α a 2 α 1 2 = a a Solving this equation system, we get: a 1 = 1 5 and a 2 = 1 5. Thus: ( F n = ) n ( ) n 5 2 c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 34 / 36

28 Solving linear recursive sequences The roots α 1,..., α k of the characteristic equ are not distinct. Say α 1 = α 2 =... = α t repeats t times. Then in the solution formula, the portion a 1 (α 1 ) n + a 2 (α 2 ) n + + a t (α t ) n is replaced by: a 1 (α 1 ) n + a 2 n 1 (α 1 ) n + + a t n t 1 (α 1 ) n Other steps are the same. c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 35 / 36

29 Example Example F 0 = 1, F 1 = 2, F 2 = 4 and for all n 0, F n+3 = 3F n+1 2F n The characteristic equation is: x 3 = 3x 2 or f (x) = x 3 3x + 2 = 0. To solve f (x) = 0, try x = 1. We find x = 1 is a root. So (x 1) is a factor of f (x). Thus f (x) = (x 1)(x 2 + x 2) = (x 1)(x 1)(x + 2). So the roots are α 1 = α 2 = 1 and α 3 = 2. The solution has the form: F n = a 1 1 n + a 2 n 1 n + a 3 ( 2) n. Plug in initial values: 1 = F 0 = a a 3 2 = F 1 = a 1 + a 2 2a 3 4 = F 2 = a 1 + 2a 2 + 4a 3 Solving this: a 1 = 8/9, a 2 = 4/3 and a 3 = 1/9 Thus: F n = n ( 2)n c Jinhui Xu (University at Buffalo) CSE 431/531 Algorithm Analysis and Design 36 / 36

Agenda. We ve discussed

Agenda. We ve discussed Agenda We ve discussed Now Next C++ basics Some built-in data structures and their applications: stack, map, vector, array The Fibonacci example showing the importance of good algorithms and asymptotic

More information

Algorithms: Background

Algorithms: Background Algorithms: Background Amotz Bar-Noy CUNY Amotz Bar-Noy (CUNY) Algorithms: Background 1 / 66 What is a Proof? Definition I: The cogency of evidence that compels acceptance by the mind of a truth or a fact.

More information

CSE 531 Homework 1 Solution. Jiayi Xian

CSE 531 Homework 1 Solution. Jiayi Xian CSE 53 Homework Solution Jiayi Xian Fall 08 . (a) True. Since f(n) O(f(n)), clearly we have O(f(n)) O(O(f(n))). For the opposite, suppose g(n) O(O(f(n))), that is c > 0, h(n) O(f(n)), s.t g(n) c h(n) as

More information

11.6: Ratio and Root Tests Page 1. absolutely convergent, conditionally convergent, or divergent?

11.6: Ratio and Root Tests Page 1. absolutely convergent, conditionally convergent, or divergent? .6: Ratio and Root Tests Page Questions ( 3) n n 3 ( 3) n ( ) n 5 + n ( ) n e n ( ) n+ n2 2 n Example Show that ( ) n n ln n ( n 2 ) n + 2n 2 + converges for all x. Deduce that = 0 for all x. Solutions

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

CS Non-recursive and Recursive Algorithm Analysis

CS Non-recursive and Recursive Algorithm Analysis CS483-04 Non-recursive and Recursive Algorithm Analysis Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/

More information

The Growth of Functions and Big-O Notation

The Growth of Functions and Big-O Notation The Growth of Functions and Big-O Notation Big-O Notation Big-O notation allows us to describe the aymptotic growth of a function without concern for i) constant multiplicative factors, and ii) lower-order

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

8.1 Sequences. Example: A sequence is a function f(n) whose domain is a subset of the integers. Notation: *Note: n = 0 vs. n = 1.

8.1 Sequences. Example: A sequence is a function f(n) whose domain is a subset of the integers. Notation: *Note: n = 0 vs. n = 1. 8. Sequences Example: A sequence is a function f(n) whose domain is a subset of the integers. Notation: *Note: n = 0 vs. n = Examples: 6. Find a formula for the general term a n of the sequence, assuming

More information

Math221: HW# 7 solutions

Math221: HW# 7 solutions Math22: HW# 7 solutions Andy Royston November 7, 25.3.3 let x = e u. Then ln x = u, x2 = e 2u, and dx = e 2u du. Furthermore, when x =, u, and when x =, u =. Hence x 2 ln x) 3 dx = e 2u u 3 e u du) = e

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

x 2 y = 1 2. Problem 2. Compute the Taylor series (at the base point 0) for the function 1 (1 x) 3.

x 2 y = 1 2. Problem 2. Compute the Taylor series (at the base point 0) for the function 1 (1 x) 3. MATH 8.0 - FINAL EXAM - SOME REVIEW PROBLEMS WITH SOLUTIONS 8.0 Calculus, Fall 207 Professor: Jared Speck Problem. Consider the following curve in the plane: x 2 y = 2. Let a be a number. The portion of

More information

CS 4407 Algorithms Lecture 2: Growth Functions

CS 4407 Algorithms Lecture 2: Growth Functions CS 4407 Algorithms Lecture 2: Growth Functions Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline Growth Functions Mathematical specification of growth functions

More information

Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010

Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Midterm Problem 1: Recall that for two functions g : N N + and h : N N +, h = Θ(g) iff for some positive integer N and positive real

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 310 Advanced Data Structures and Algorithms Runtime Analysis May 31, 2017 Tong Wang UMass Boston CS 310 May 31, 2017 1 / 37 Topics Weiss chapter 5 What is algorithm analysis Big O, big, big notations

More information

Divide and Conquer Strategy

Divide and Conquer Strategy Divide and Conquer Strategy Algorithm design is more an art, less so a science. There are a few useful strategies, but no guarantee to succeed. We will discuss: Divide and Conquer, Greedy, Dynamic Programming.

More information

Appendix: Solving Recurrences

Appendix: Solving Recurrences ... O Zarathustra, who you are and must become behold you are the teacher of the eternal recurrence that is your destiny! That you as the first must teach this doctrine how could this great destiny not

More information

i=1 i B[i] B[i] + A[i, j]; c n for j n downto i + 1 do c n i=1 (n i) C[i] C[i] + A[i, j]; c n

i=1 i B[i] B[i] + A[i, j]; c n for j n downto i + 1 do c n i=1 (n i) C[i] C[i] + A[i, j]; c n Fundamental Algorithms Homework #1 Set on June 25, 2009 Due on July 2, 2009 Problem 1. [15 pts] Analyze the worst-case time complexity of the following algorithms,and give tight bounds using the Theta

More information

Lecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole.

Lecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole. Lecture 1: Asymptotic Complexity 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole. Announcements TA office hours officially start this week see

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

CS 4104 Data and Algorithm Analysis. Recurrence Relations. Modeling Recursive Function Cost. Solving Recurrences. Clifford A. Shaffer.

CS 4104 Data and Algorithm Analysis. Recurrence Relations. Modeling Recursive Function Cost. Solving Recurrences. Clifford A. Shaffer. Department of Computer Science Virginia Tech Blacksburg, Virginia Copyright c 2010,2017 by Clifford A. Shaffer Data and Algorithm Analysis Title page Data and Algorithm Analysis Clifford A. Shaffer Spring

More information

CSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee

CSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee CSCE 222 Discrete Structures for Computing Sequences and Summations Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1 Sequences 2 Sequences A sequence is a function from a subset of the set of

More information

Because of the special form of an alternating series, there is an simple way to determine that many such series converge:

Because of the special form of an alternating series, there is an simple way to determine that many such series converge: Section.5 Absolute and Conditional Convergence Another special type of series that we will consider is an alternating series. A series is alternating if the sign of the terms alternates between positive

More information

Section 9.8. First let s get some practice with determining the interval of convergence of power series.

Section 9.8. First let s get some practice with determining the interval of convergence of power series. First let s get some practice with determining the interval of convergence of power series. First let s get some practice with determining the interval of convergence of power series. Example (1) Determine

More information

Given a sequence a 1, a 2,...of numbers, the finite sum a 1 + a 2 + +a n,wheren is an nonnegative integer, can be written

Given a sequence a 1, a 2,...of numbers, the finite sum a 1 + a 2 + +a n,wheren is an nonnegative integer, can be written A Summations When an algorithm contains an iterative control construct such as a while or for loop, its running time can be expressed as the sum of the times spent on each execution of the body of the

More information

Ch01. Analysis of Algorithms

Ch01. Analysis of Algorithms Ch01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T. Goodrich

More information

Review Sheet on Convergence of Series MATH 141H

Review Sheet on Convergence of Series MATH 141H Review Sheet on Convergence of Series MATH 4H Jonathan Rosenberg November 27, 2006 There are many tests for convergence of series, and frequently it can been confusing. How do you tell what test to use?

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

Math 0230 Calculus 2 Lectures

Math 0230 Calculus 2 Lectures Math 00 Calculus Lectures Chapter 8 Series Numeration of sections corresponds to the text James Stewart, Essential Calculus, Early Transcendentals, Second edition. Section 8. Sequences A sequence is a

More information

Searching. Sorting. Lambdas

Searching. Sorting. Lambdas .. s Babes-Bolyai University arthur@cs.ubbcluj.ro Overview 1 2 3 Feedback for the course You can write feedback at academicinfo.ubbcluj.ro It is both important as well as anonymous Write both what you

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

Lecture 2: Asymptotic Notation CSCI Algorithms I

Lecture 2: Asymptotic Notation CSCI Algorithms I Lecture 2: Asymptotic Notation CSCI 700 - Algorithms I Andrew Rosenberg September 2, 2010 Last Time Review Insertion Sort Analysis of Runtime Proof of Correctness Today Asymptotic Notation Its use in analyzing

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

Chapter 8. Infinite Series

Chapter 8. Infinite Series 8.4 Series of Nonnegative Terms Chapter 8. Infinite Series 8.4 Series of Nonnegative Terms Note. Given a series we have two questions:. Does the series converge? 2. If it converges, what is its sum? Corollary

More information

Asymptotic Analysis 1

Asymptotic Analysis 1 Asymptotic Analysis 1 Last week, we discussed how to present algorithms using pseudocode. For example, we looked at an algorithm for singing the annoying song 99 Bottles of Beer on the Wall for arbitrary

More information

data structures and algorithms lecture 2

data structures and algorithms lecture 2 data structures and algorithms 2018 09 06 lecture 2 recall: insertion sort Algorithm insertionsort(a, n): for j := 2 to n do key := A[j] i := j 1 while i 1 and A[i] > key do A[i + 1] := A[i] i := i 1 A[i

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

The integral test and estimates of sums

The integral test and estimates of sums The integral test Suppose f is a continuous, positive, decreasing function on [, ) and let a n = f (n). Then the series n= a n is convergent if and only if the improper integral f (x)dx is convergent.

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?

More information

Algorithms. Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY. Algorihms, A.Yazici, Fall 2007 CEng 315

Algorithms. Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY. Algorihms, A.Yazici, Fall 2007 CEng 315 Algorithms Adnan YAZICI Dept. of Computer Engineering Middle East Technical Univ. Ankara - TURKEY Algorihms, A.Yazici, Fall 2007 CEng 315 1 Design and Analysis of Algorithms Aspects of studying algorithms:

More information

Chapter 11 - Sequences and Series

Chapter 11 - Sequences and Series Calculus and Analytic Geometry II Chapter - Sequences and Series. Sequences Definition. A sequence is a list of numbers written in a definite order, We call a n the general term of the sequence. {a, a

More information

282 Math Preview. Chris Brown. September 8, Why This? 2. 2 Logarithms Basic Identities Basic Consequences...

282 Math Preview. Chris Brown. September 8, Why This? 2. 2 Logarithms Basic Identities Basic Consequences... 282 Math Preview Chris Brown September 8, 2005 Contents Why This? 2 2 Logarithms 2 2. Basic Identities.................................... 2 2.2 Basic Consequences.................................. 3 3

More information

Section 11.1 Sequences

Section 11.1 Sequences Math 152 c Lynch 1 of 8 Section 11.1 Sequences A sequence is a list of numbers written in a definite order: a 1, a 2, a 3,..., a n,... Notation. The sequence {a 1, a 2, a 3,...} can also be written {a

More information

Lecture 6 September 21, 2016

Lecture 6 September 21, 2016 ICS 643: Advanced Parallel Algorithms Fall 2016 Lecture 6 September 21, 2016 Prof. Nodari Sitchinava Scribe: Tiffany Eulalio 1 Overview In the last lecture, we wrote a non-recursive summation program and

More information

n=1 ( 2 3 )n (a n ) converges by direct comparison to

n=1 ( 2 3 )n (a n ) converges by direct comparison to . (a) n = a n converges, so we know that a n =. Therefore, for n large enough we know that a n

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

1 + lim. n n+1. f(x) = x + 1, x 1. and we check that f is increasing, instead. Using the quotient rule, we easily find that. 1 (x + 1) 1 x (x + 1) 2 =

1 + lim. n n+1. f(x) = x + 1, x 1. and we check that f is increasing, instead. Using the quotient rule, we easily find that. 1 (x + 1) 1 x (x + 1) 2 = Chapter 5 Sequences and series 5. Sequences Definition 5. (Sequence). A sequence is a function which is defined on the set N of natural numbers. Since such a function is uniquely determined by its values

More information

Math 132 Exam 3 Fall 2016

Math 132 Exam 3 Fall 2016 Math 3 Exam 3 Fall 06 multiple choice questions worth points each. hand graded questions worth and 3 points each. Exam covers sections.-.6: Sequences, Series, Integral, Comparison, Alternating, Absolute

More information

Assignment 4. u n+1 n(n + 1) i(i + 1) = n n (n + 1)(n + 2) n(n + 2) + 1 = (n + 1)(n + 2) 2 n + 1. u n (n + 1)(n + 2) n(n + 1) = n

Assignment 4. u n+1 n(n + 1) i(i + 1) = n n (n + 1)(n + 2) n(n + 2) + 1 = (n + 1)(n + 2) 2 n + 1. u n (n + 1)(n + 2) n(n + 1) = n Assignment 4 Arfken 5..2 We have the sum Note that the first 4 partial sums are n n(n + ) s 2, s 2 2 3, s 3 3 4, s 4 4 5 so we guess that s n n/(n + ). Proving this by induction, we see it is true for

More information

Recursion. Computational complexity

Recursion. Computational complexity List. Babes-Bolyai University arthur@cs.ubbcluj.ro Overview List 1 2 List Second Laboratory Test List Will take place week 12, during the laboratory You will receive one problem statement, from what was

More information

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form

Solutions. Problem 1: Suppose a polynomial in n of degree d has the form Assignment 1 1. Problem 3-1 on p. 57 2. Problem 3-2 on p. 58 3. Problem 4-5 on p. 86 4. Problem 6-1 on p. 142 5. Problem 7-4 on p. 162 6. Prove correctness (including halting) of SelectionSort (use loop

More information

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity CSE 417: Algorithms and Computational Complexity Lecture 2: Analysis Larry Ruzzo 1 Why big-o: measuring algorithm efficiency outline What s big-o: definition and related concepts Reasoning with big-o:

More information

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem

CS 577 Introduction to Algorithms: Strassen s Algorithm and the Master Theorem CS 577 Introduction to Algorithms: Jin-Yi Cai University of Wisconsin Madison In the last class, we described InsertionSort and showed that its worst-case running time is Θ(n 2 ). Check Figure 2.2 for

More information

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional)

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional) Section 2.4 Section Summary Sequences. o Examples: Geometric Progression, Arithmetic Progression Recurrence Relations o Example: Fibonacci Sequence Summations Special Integer Sequences (optional) Sequences

More information

SOLUTIONS TO EXAM II, MATH f(x)dx where a table of values for the function f(x) is given below.

SOLUTIONS TO EXAM II, MATH f(x)dx where a table of values for the function f(x) is given below. SOLUTIONS TO EXAM II, MATH 56 Use Simpson s rule with n = 6 to approximate the integral f(x)dx where a table of values for the function f(x) is given below x 5 5 75 5 5 75 5 5 f(x) - - x 75 5 5 75 5 5

More information

Lecture 5: Loop Invariants and Insertion-sort

Lecture 5: Loop Invariants and Insertion-sort Lecture 5: Loop Invariants and Insertion-sort COMS10007 - Algorithms Dr. Christian Konrad 11.01.2019 Dr. Christian Konrad Lecture 5: Loop Invariants and Insertion-sort 1 / 12 Proofs by Induction Structure

More information

Algorithm efficiency analysis

Algorithm efficiency analysis Algorithm efficiency analysis Mădălina Răschip, Cristian Gaţu Faculty of Computer Science Alexandru Ioan Cuza University of Iaşi, Romania DS 2017/2018 Content Algorithm efficiency analysis Recursive function

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

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

Discrete Structures: Sample Questions, Exam 2, SOLUTIONS

Discrete Structures: Sample Questions, Exam 2, SOLUTIONS Discrete Structures: Sample Questions, Exam, SOLUTIONS This is longer than the actual test.) 1. List all the strings over X = {a, b, c} of length or less. λ, a, b, c, aa, ab, ac, ba, bb, bc, ca, cb, cc..

More information

Ch 01. Analysis of Algorithms

Ch 01. Analysis of Algorithms Ch 01. Analysis of Algorithms Input Algorithm Output Acknowledgement: Parts of slides in this presentation come from the materials accompanying the textbook Algorithm Design and Applications, by M. T.

More information

Week 2: Sequences and Series

Week 2: Sequences and Series QF0: Quantitative Finance August 29, 207 Week 2: Sequences and Series Facilitator: Christopher Ting AY 207/208 Mathematicians have tried in vain to this day to discover some order in the sequence of prime

More information

A = (a + 1) 2 = a 2 + 2a + 1

A = (a + 1) 2 = a 2 + 2a + 1 A = (a + 1) 2 = a 2 + 2a + 1 1 A = ( (a + b) + 1 ) 2 = (a + b) 2 + 2(a + b) + 1 = a 2 + 2ab + b 2 + 2a + 2b + 1 A = ( (a + b) + 1 ) 2 = (a + b) 2 + 2(a + b) + 1 = a 2 + 2ab + b 2 + 2a + 2b + 1 3 A = (

More information

Module 1: Analyzing the Efficiency of Algorithms

Module 1: Analyzing the Efficiency of Algorithms Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Based

More information

Time Analysis of Sorting and Searching Algorithms

Time Analysis of Sorting and Searching Algorithms Time Analysis of Sorting and Searching Algorithms CSE21 Winter 2017, Day 5 (B00), Day 3 (A00) January 20, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Big-O : How to determine? Is f(n) big-o of g(n)?

More information

Design Patterns for Data Structures. Chapter 3. Recursive Algorithms

Design Patterns for Data Structures. Chapter 3. Recursive Algorithms Chapter 3 Recursive Algorithms Writing recurrences + Writing recurrences To determine the statement execution count is a two-step problem. Write down the recurrence from the recursive code for the algorithm.

More information

MATH 18.01, FALL PROBLEM SET #5 SOLUTIONS (PART II)

MATH 18.01, FALL PROBLEM SET #5 SOLUTIONS (PART II) MATH 8, FALL 7 - PROBLEM SET #5 SOLUTIONS (PART II (Oct ; Antiderivatives; + + 3 7 points Recall that in pset 3A, you showed that (d/dx tanh x x Here, tanh (x denotes the inverse to the hyperbolic tangent

More information

Review (11.1) 1. A sequence is an infinite list of numbers {a n } n=1 = a 1, a 2, a 3, The sequence is said to converge if lim

Review (11.1) 1. A sequence is an infinite list of numbers {a n } n=1 = a 1, a 2, a 3, The sequence is said to converge if lim Announcements: Note that we have taking the sections of Chapter, out of order, doing section. first, and then the rest. Section. is motivation for the rest of the chapter. Do the homework questions from

More information

1 Useful identities related to summations

1 Useful identities related to summations 1 Chris Piech CS 109 Calculation Reference Sept 26, 2018 Autumn Handout by Mehran Sahami 1 Useful identities related to summations Since it may have been a while since some folks have worked with summations,

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

Calculus of Finite Differences. Andreas Klappenecker

Calculus of Finite Differences. Andreas Klappenecker Calculus of Finite Differences Andreas Klappenecker Motivation When we analyze the runtime of algorithms, we simply count the number of operations. For example, the following loop for k = 1 to n do square(k);

More information

COMPUTER ALGORITHMS. Athasit Surarerks.

COMPUTER ALGORITHMS. Athasit Surarerks. COMPUTER ALGORITHMS Athasit Surarerks. Introduction EUCLID s GAME Two players move in turn. On each move, a player has to write on the board a positive integer equal to the different from two numbers already

More information

Convergence of sequences and series

Convergence of sequences and series Convergence of sequences and series A sequence f is a map from N the positive integers to a set. We often write the map outputs as f n rather than f(n). Often we just list the outputs in order and leave

More information

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

Appendix II: 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

More information

CS473 - Algorithms I

CS473 - Algorithms I CS473 - Algorithms I Lecture 2 Asymptotic Notation 1 O-notation: Asymptotic upper bound f(n) = O(g(n)) if positive constants c, n 0 such that 0 f(n) cg(n), n n 0 f(n) = O(g(n)) cg(n) f(n) Asymptotic running

More information

Analysis of Algorithms

Analysis of Algorithms Analysis of Algorithms Section 4.3 Prof. Nathan Wodarz Math 209 - Fall 2008 Contents 1 Analysis of Algorithms 2 1.1 Analysis of Algorithms....................... 2 2 Complexity Analysis 4 2.1 Notation

More information

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming

Algorithms and Theory of Computation. Lecture 9: Dynamic Programming Algorithms and Theory of Computation Lecture 9: Dynamic Programming Xiaohui Bei MAS 714 September 10, 2018 Nanyang Technological University MAS 714 September 10, 2018 1 / 21 Recursion in Algorithm Design

More information

Enumerate all possible assignments and take the An algorithm is a well-defined computational

Enumerate all possible assignments and take the An algorithm is a well-defined computational EMIS 8374 [Algorithm Design and Analysis] 1 EMIS 8374 [Algorithm Design and Analysis] 2 Designing and Evaluating Algorithms A (Bad) Algorithm for the Assignment Problem Enumerate all possible assignments

More information

Power Series. Part 1. J. Gonzalez-Zugasti, University of Massachusetts - Lowell

Power Series. Part 1. J. Gonzalez-Zugasti, University of Massachusetts - Lowell Power Series Part 1 1 Power Series Suppose x is a variable and c k & a are constants. A power series about x = 0 is c k x k A power series about x = a is c k x a k a = center of the power series c k =

More information

Order Notation and the Mathematics for Analysis of Algorithms

Order Notation and the Mathematics for Analysis of Algorithms Elementary Data Structures and Algorithms Order Notation and the Mathematics for Analysis of Algorithms Name: Email: Code: 19704 Always choose the best or most general answer, unless otherwise instructed.

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

d(x n, x) d(x n, x nk ) + d(x nk, x) where we chose any fixed k > N

d(x n, x) d(x n, x nk ) + d(x nk, x) where we chose any fixed k > N Problem 1. Let f : A R R have the property that for every x A, there exists ɛ > 0 such that f(t) > ɛ if t (x ɛ, x + ɛ) A. If the set A is compact, prove there exists c > 0 such that f(x) > c for all x

More information

CS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, Problem 3-1.

CS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, Problem 3-1. CS161: Algorithm Design and Analysis Recitation Section 3 Stanford University Week of 29 January, 2018 Problem 3-1. (Quicksort Median-of-3 Partition) One way to improve the randomized quicksort procedure

More information

International Competition in Mathematics for Universtiy Students in Plovdiv, Bulgaria 1994

International Competition in Mathematics for Universtiy Students in Plovdiv, Bulgaria 1994 International Competition in Mathematics for Universtiy Students in Plovdiv, Bulgaria 1994 1 PROBLEMS AND SOLUTIONS First day July 29, 1994 Problem 1. 13 points a Let A be a n n, n 2, symmetric, invertible

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

Assignment 16 Assigned Weds Oct 11

Assignment 16 Assigned Weds Oct 11 Assignment 6 Assigned Weds Oct Section 8, Problem 3 a, a 3, a 3 5, a 4 7 Section 8, Problem 4 a, a 3, a 3, a 4 3 Section 8, Problem 9 a, a, a 3, a 4 4, a 5 8, a 6 6, a 7 3, a 8 64, a 9 8, a 0 56 Section

More information

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2

Asymptotic Analysis. Slides by Carl Kingsford. Jan. 27, AD Chapter 2 Asymptotic Analysis Slides by Carl Kingsford Jan. 27, 2014 AD Chapter 2 Independent Set Definition (Independent Set). Given a graph G = (V, E) an independent set is a set S V if no two nodes in S are joined

More information

CSC2100B Data Structures Analysis

CSC2100B Data Structures Analysis CSC2100B Data Structures Analysis Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Algorithm An algorithm

More information

CS 361, Lecture 14. Outline

CS 361, Lecture 14. Outline Bucket Sort CS 361, Lecture 14 Jared Saia University of New Mexico Bucket sort assumes that the input is drawn from a uniform distribution over the range [0, 1) Basic idea is to divide the interval [0,

More information

CSCI Honor seminar in algorithms Homework 2 Solution

CSCI Honor seminar in algorithms Homework 2 Solution CSCI 493.55 Honor seminar in algorithms Homework 2 Solution Saad Mneimneh Visiting Professor Hunter College of CUNY Problem 1: Rabin-Karp string matching Consider a binary string s of length n and another

More information

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3 Banner ID: Name: Midterm Exam CS 3110: Design and Analysis of Algorithms June 20, 2006 Group 1 Group 2 Group 3 Question 1.1 Question 2.1 Question 3.1 Question 1.2 Question 2.2 Question 3.2 Question 3.3

More information

1 The distributive law

1 The distributive law THINGS TO KNOW BEFORE GOING INTO DISCRETE MATHEMATICS The distributive law The distributive law is this: a(b + c) = ab + bc This can be generalized to any number of terms between parenthesis; for instance:

More information

Assignment 16 Solution. Please do not copy and paste my answer. You will get similar questions but with different numbers!

Assignment 16 Solution. Please do not copy and paste my answer. You will get similar questions but with different numbers! Assignment 6 Solution Please do not copy and paste my answer. You will get similar questions but with different numbers! Suppose f is a continuous, positive, decreasing function on [, ) and let a n = f

More information

Lecture II RECURRENCES

Lecture II RECURRENCES Lecture II Page Lecture II RECURRENCES Recurrences arise naturally in analyzing the complexity of recursive algorithms and in probabilistic analysis. We introduce some basic techniques for solving recurrences.

More information

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency

Lecture 2. Fundamentals of the Analysis of Algorithm Efficiency Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms

More information

Math 112 Rahman. Week Taylor Series Suppose the function f has the following power series:

Math 112 Rahman. Week Taylor Series Suppose the function f has the following power series: Math Rahman Week 0.8-0.0 Taylor Series Suppose the function f has the following power series: fx) c 0 + c x a) + c x a) + c 3 x a) 3 + c n x a) n. ) Can we figure out what the coefficients are? Yes, yes

More information

Cookie Monster Meets the Fibonacci Numbers. Mmmmmm Theorems!

Cookie Monster Meets the Fibonacci Numbers. Mmmmmm Theorems! Cookie Monster Meets the Fibonacci Numbers. Mmmmmm Theorems! Steven J. Miller (MC 96) http://www.williams.edu/mathematics/sjmiller/public_html Yale University, April 14, 2014 Introduction Goals of the

More information

Written Homework #1: Analysis of Algorithms

Written Homework #1: Analysis of Algorithms Written Homework #1: Analysis of Algorithms CIS 121 Fall 2016 cis121-16fa-staff@googlegroups.com Due: Thursday, September 15th, 2015 before 10:30am (You must submit your homework online via Canvas. A paper

More information

CMSC Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005

CMSC Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005 CMSC-37110 Discrete Mathematics SOLUTIONS TO SECOND MIDTERM EXAM November, 2005 Instructor: László Babai Ryerson 164 e-mail: laci@cs This exam contributes 20% to your course grade. 1. (6 points) Let a

More information

Lecture 2: Randomized Algorithms

Lecture 2: Randomized Algorithms Lecture 2: Randomized Algorithms Independence & Conditional Probability Random Variables Expectation & Conditional Expectation Law of Total Probability Law of Total Expectation Derandomization Using Conditional

More information