COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

Size: px
Start display at page:

Download "COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro"

Transcription

1 COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk

2 Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T. ad Roberto Tamassia (chapter 8) Itroductio to Algorithms, Corme, Leiserso, Rivest, Stei (chapters 2 ad 4)

3 Iteded Learig Outcomes Review expoetials, logarithms, factorials, ad sums Solve recurreces usig iteratio method ad master method Describe various examples to aalyse dividead-coquer algorithms ad how to solve their recurreces

4 Expoetials For all real a > 0, m, ad, we have the followig idetities: a 0 1, a 1 a, a -1 1/a, (a m ) a m, a m a a m. For all ad a 1, the fuctio a is mootoically icreasig i

5 Logarithms For all real a > 0, b > 0, c > 0, ad, i each equatio above, logarithm bases are ot 1

6 Factorials The otatio! is defied for itegers 0 as A form of Stirlig s approximatio A weak upper boud o the factorial fuctio is! sice each of the terms i the factorial product is at most

7 Sums Give a sequece of a 1, a 2,, a of umbers, where is a oegative iteger, we ca write the fiite sum a 1 a 2 a as If 0, the value of the summatio is 0 Give a ifiite sequece of a 1, a 2,, a If the limit does ot exist, the series diverges; If the limit exists ad is fiite, the series coverges

8 Algebraic Regroupig Distributive: A commo factor ca be distributed over all the summads Additio: Add each pair of summads with the same idex (a k b k ) a k b k k K ca k c a k k K Permutatio: The value of a sum is uchaged by permutig the order of the summads k K k K k K a k a P (k ) k K p (k ) K

9 Arithmetic ad Geometric Series The summatio is a arithmetic series ad has the value For real x 1, the summatio is a geometric series ad has the value

10 The Perturbatio Method The iitial step of a perturbatio is to equate two expressios for S 1 by takig its first ad last terms Fid S o both sides of the equatio Isolate S to fid the formula for the sum What makes it iterestig is ot the theory behid it, but the fact that it works so effectively so ofte for sums that cotai expoetials

11 S Illustrative Example of the x k k 0 S 1 S x 1 Perturbatio Method Give our geometric series: 1 k 1 k 0 k 0 S 1 x 0 x k 1 x k 1 1 x x k 1 xs 1 xs S x 1 S x 1 1 x 1 Obtai the last term Obtai the first term

12 Approximatio by Itegrals Whe a summatio has the form, where f(k) is a mootoically icreasig fuctio, we ca approximate it by itegrals

13 Approximatio by Itegrals (Cot.) Whe f(k) is a mootoically decreasig fuctio, we ca use a similar method to provide the bouds First iequality which yields the boud Secod iequality

14 Solvig Recurreces I additio to the substitutio method, aother optio is what the literature calls the iteratio method Expad the recurrece Work some algebra to express as a summatio Evaluate the summatio We will show several examples

15 Example 1: Iteratio What is the complexity of this recurrece? s( ) c 0 s( 1) > 0 0

16 Example 1: Iteratio s() c s(-1) c c s(-2) c c c s(-3) 3c s(-3) kc s(-k) ck s(-k) s() c s(-1) s(-1) c s(-2) s(-2) c s(-3) s( ) c 0 s( 1) > 0 0

17 Example 1: Iteratio So far for > k we have s() ck s(-k) if k? s() c s(0) c The s() c s() O() s( ) c 0 s( 1) > 0 0

18 Example 2: Iteratio What is the complexity of this recurrece? s( ) 0 s( 1) > 0 0

19 Example 2: Iteratio k1 k2 s() s(-1) -1 s(-2) s( ) 0 s( 1) > 0 0 k s(-3) k s(-4) (k-1) s(-k) i i k 1 s( k)

20 So far for > k we have If k? The: ) ( 1 k s i k i (0) 1 1 i s i i i 2 1 ) ( s Example 2: Iteratio (Arithmetic series) s() O( 2 )

21 Example 3: Iteratio What is the complexity of this recurrece? T( ) 2T c 2 c 1 > 1

22 Example 3: Iteratio T() 2T(/2) c 2(2T(/2/2) c) c 2 2 T(/2 2 ) 2c c 2 2 (2T(/2 2 /2) c) 3c 2 3 T(/2 3 ) 4c 3c 2 3 T(/2 3 ) 7c 2 3 (2T(/2 3 /2) c) 7c 2 4 T(/2 4 ) 15c 2 k T(/2 k ) (2 k T( ) - 1)c c 2T c 2 1 > 1

23 Example 3: Iteratio So far for > 2 k we have T() 2 k T(/2 k ) (2 k - 1)c If klg? T() 2 log T(/2 log ) (2 log - 1)c T(/) ( - 1)c T(1) (-1)c c (-1)c (2-1)c a log b c c log b a T() O() T( ) c 2T c 2 1 > 1

24 Example 4: Iteratio What is the recurrece equatio? MergeSort(A, left, right) { if (left < right) { } } mid floor((left right) / 2); MergeSort(A, left, mid); MergeSort(A, mid1, right); Merge(A, left, mid, right); What is the complexity of this recurrece? T( ) at c b c 1 > 1

25 Example 4: Iteratio T() at(/b) c a(at(/b/b) c/b) c a 2 T(/b 2 ) ca/b c a 2 T(/b 2 ) c(a/b 1) T( ) at a 2 (at(/b 2 /b) c/b 2 ) c(a/b 1) a 3 T(/b 3 ) c(a 2 /b 2 ) c(a/b 1) a 3 T(/b 3 ) c(a 2 /b 2 a/b 1) a k T(/b k ) c(a k-1 /b k-1 a k-2 /b k-2 a 2 /b 2 a/b 1) c b c 1 > 1

26 Example 4: Iteratio So we have T() a k T(/b k ) c(a k-1 /b k-1... a 2 /b 2 a/b 1) For k log b b k T() a k T(1) c(a k-1 /b k-1... a 2 /b 2 a/b 1) a k c c(a k-1 /b k-1... a 2 /b 2 a/b 1) ca k c(a k-1 /b k-1... a 2 /b 2 a/b 1) c(a k / a k-1 /b k-1... a 2 /b 2 a/b 1) c(a k /b k a k-1 /b k-1... a 2 /b 2 a/b 1)

27 Example 4: Iteratio The, for k log b T() c(a k /b k... a 2 /b 2 a/b 1) If a b? T() c(k 1) c(log b 1) Θ( log b ) k

28 If a < b? Note that: We have: The: ( ) ( ) ( ) ( ) b a b a b a b a b a b a b a b a k k k k k k < ! T() c Θ(1) Θ() T() c(a k /b k... a 2 /b 2 a/b 1) ( ) x x x x x x x k k k k Example 4: Iteratio

29 Example 4: Iteratio If a > b? T() c(a k /b k... a 2 /b 2 a/b 1) a b k k a b k 1 k 1! a b 1 T() c Θ(a k / b k ) k ( a b) ( a b) Θ ( a b) k ) c Θ(a log b / b log b ) c Θ(a log b / ) sice a log b log b a c Θ( log b a / ) Θ(c log b a / ) Θ( log b a )

30 Example 4: Iteratio Therefore T () Θ( ) a < b Θ( log ) a b b ( Θ log b a ) a > b

31 The Master Theorem Give: a divide ad coquer algorithm A algorithm that divides the problem of size ito a subproblems, each of size /b Let the cost of each stage (i.e., the work to divide the problem D() combie solved subproblems C()) be described by the fuctio f()d()c() The master method provides a cookbook method for solvig recurreces of the form

32 The Master Theorem (cot.) if T() at(/b) f() the T () Θ( log b a ) Θ( log b a log) Θ( f ()) f () O ( log b a ε ) f () Θ( log b a ) f () Ω( log b a ε ) AND af ( / b) cf () for large ε > 0 c <1

33 The Master Theorem (cot.) Used for the solutio of this type of recurreces T ( ) atb ( / ) f ( ) a 1, b>1, ad f asymptotically positive; Sice T() is the executio time of the algorithm, we ca state that Sub-problems of size /b are solved recursively each oe i time T(/b) f() is the cost to divide the problem ad combie its results. I MergeSort we have: T ( ) 2 T ( /2) ( ) Θ a 2, b 2, f ( ) Θ( )

34 Cookbook Method Step 1: Idetify a, b e f () Step 2: Determie log b a Step 3: Compare f () to log b a asymptotically Step 4: Accordig to the case, apply the correspodig rule

35 Example 1 T() 9T(/3) Step 1: a9, b3, f() Step 2: log b a log Step 3: f() O( log ε ), O() where ε1 Step 4: case 1 applies: if f () O ( log b a ε ) for some costat ε > 0,the T () Θ ( log b a ) Therefore T() Θ( 2 )

36 Example 2 T() T(2/3) 1 Step 1: a 1, b 3/2, f() 1 Step 2: log b a log 3/ Step 3: f() Θ( log b a ) Θ(1) Step 4: case 2 applies: if f () Θ( log b a ), the T () Θ ( log b a log) Therefore T() Θ(log )

37 Example 3 T() 3T(/4) log Step 1: a 3, b 4, f() log Step 2: log b a log Step 3: f() Ω( log 4 3ε ), where ε 0.2 Step 4: case 3 applies: If f() Ω( log b aε ) for some costat ε > 0, ad if af(/b) cf() for some costat c < 1 ad all sufficietly large, the T() Θ(f())

38 Example 3 (Cot.) If f() Ω( log b aε ) for some costat ε > 0, ad if af(/b) cf() for some costat c < 1 ad all sufficietly large, the T() Θ(f()) For sufficietly large, we have that af(/b) 3(/4) log (/4) (3/4) log for c ¾ Therefore T() Θ( log )

39 Example 4 (Merge Sort) T ( ) 2 T ( / 2) Θ( ) a b Θ log b a log 2 2, 2; 2 ( ) Give f( ) Θ( ) We have case 2: if f () Θ( log b a ), the T () Θ ( log b a log) which leads to: T () Θ( log b a log ) Θ ( log )

40 Exercises What is the recurrece equatio of these programs? fac() if 1 retur 1 else retur * fac(-1) smallest(list, start, ed) if start ed-1 retur list[start] else mid (started)/2 small1 smallest(list, start, mid) small2 smallest(list, mid1, ed) retur smallest of small1 ad small2

41 Exercises What is the recurrece equatio of these programs? idex bisearch(umber, idex low, idex high, cost keytype S[], keytype x) if low high the mid (low high) / 2 if x S[mid] the retur mid elsif x < s[mid] the retur bisearch(, low, mid-1, S, x) else retur bisearch(, mid1, high, S, x) else retur 0 ed bisearch

42 Exercises Use the substitutio, iteratio or master method to solve the followig recurreces: a) T() T(-1) O(1) (Factorial) b) T() 2T(/2) O(1) (Smallest) c) T() T(/2) Θ(1) (Biary Search)

43 Summary May useful algorithms are recursive i structure: they call themselves recursively oe or more times to deal with closely related sub-problems We also aalysed recurreces usig the followig methods: substitutio Iteratio master We have demostrated the recurrece equatio ad its complexity for factorial, smallest, ad biary search

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2 This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is

More information

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis

More information

Fundamental Algorithms

Fundamental Algorithms Fudametal Algorithms Chapter 2b: Recurreces Michael Bader Witer 2014/15 Chapter 2b: Recurreces, Witer 2014/15 1 Recurreces Defiitio A recurrece is a (i-equality that defies (or characterizes a fuctio i

More information

Algorithms and Data Structures Lecture IV

Algorithms and Data Structures Lecture IV Algorithms ad Data Structures Lecture IV Simoas Šalteis Aalborg Uiversity simas@cs.auc.dk September 5, 00 1 This Lecture Aalyzig the ruig time of recursive algorithms (such as divide-ad-coquer) Writig

More information

INFINITE SEQUENCES AND SERIES

INFINITE SEQUENCES AND SERIES 11 INFINITE SEQUENCES AND SERIES INFINITE SEQUENCES AND SERIES 11.4 The Compariso Tests I this sectio, we will lear: How to fid the value of a series by comparig it with a kow series. COMPARISON TESTS

More information

Unit 6: Sequences and Series

Unit 6: Sequences and Series AMHS Hoors Algebra 2 - Uit 6 Uit 6: Sequeces ad Series 26 Sequeces Defiitio: A sequece is a ordered list of umbers ad is formally defied as a fuctio whose domai is the set of positive itegers. It is commo

More information

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs. CS23 Algorithms Hadout #6 Prof Ly Turbak September 8, 200 Wellesley College RECURRENCES This hadout summarizes highlights of CLRS Chapter 4 ad Appedix A (CLR Chapters 3 & 4) Two-Step Strategy for Aalyzig

More information

is also known as the general term of the sequence

is also known as the general term of the sequence Lesso : Sequeces ad Series Outlie Objectives: I ca determie whether a sequece has a patter. I ca determie whether a sequece ca be geeralized to fid a formula for the geeral term i the sequece. I ca determie

More information

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc) Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:

More information

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.5703) ALGORITHM ANALYSIS AND DESIGN (3 cr.) (T) Topics of curret iterest i the desig ad aalysis of computer algorithms for graphtheoretical

More information

4.3 Growth Rates of Solutions to Recurrences

4.3 Growth Rates of Solutions to Recurrences 4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.

More information

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects

More information

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018 CSE 353 Discrete Computatioal Structures Sprig 08 Sequeces, Mathematical Iductio, ad Recursio (Chapter 5, Epp) Note: some course slides adopted from publisher-provided material Overview May mathematical

More information

Recurrence Relations

Recurrence Relations Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The

More information

Mathematical Foundation. CSE 6331 Algorithms Steve Lai

Mathematical Foundation. CSE 6331 Algorithms Steve Lai Mathematical Foudatio CSE 6331 Algorithms Steve Lai Complexity of Algorithms Aalysis of algorithm: to predict the ruig time required by a algorithm. Elemetary operatios: arithmetic & boolea operatios:

More information

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis Mathematics review for CSCI 303 Sprig 019 Departmet of Computer Sciece College of William & Mary Robert Michael Lewis Copyright 018 019 Robert Michael Lewis Versio geerated: 13 : 00 Jauary 17, 019 Cotets

More information

Definition An infinite sequence of numbers is an ordered set of real numbers.

Definition An infinite sequence of numbers is an ordered set of real numbers. Ifiite sequeces (Sect. 0. Today s Lecture: Review: Ifiite sequeces. The Cotiuous Fuctio Theorem for sequeces. Usig L Hôpital s rule o sequeces. Table of useful its. Bouded ad mootoic sequeces. Previous

More information

62. Power series Definition 16. (Power series) Given a sequence {c n }, the series. c n x n = c 0 + c 1 x + c 2 x 2 + c 3 x 3 +

62. Power series Definition 16. (Power series) Given a sequence {c n }, the series. c n x n = c 0 + c 1 x + c 2 x 2 + c 3 x 3 + 62. Power series Defiitio 16. (Power series) Give a sequece {c }, the series c x = c 0 + c 1 x + c 2 x 2 + c 3 x 3 + is called a power series i the variable x. The umbers c are called the coefficiets of

More information

Sequences, Sums, and Products

Sequences, Sums, and Products CSCE 222 Discrete Structures for Computig Sequeces, Sums, ad Products Dr. Philip C. Ritchey Sequeces A sequece is a fuctio from a subset of the itegers to a set S. A discrete structure used to represet

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Infinite Series and Improper Integrals

Infinite Series and Improper Integrals 8 Special Fuctios Ifiite Series ad Improper Itegrals Ifiite series are importat i almost all areas of mathematics ad egieerig I additio to umerous other uses, they are used to defie certai fuctios ad to

More information

ENGI Series Page 6-01

ENGI Series Page 6-01 ENGI 3425 6 Series Page 6-01 6. Series Cotets: 6.01 Sequeces; geeral term, limits, covergece 6.02 Series; summatio otatio, covergece, divergece test 6.03 Stadard Series; telescopig series, geometric series,

More information

Physics 116A Solutions to Homework Set #1 Winter Boas, problem Use equation 1.8 to find a fraction describing

Physics 116A Solutions to Homework Set #1 Winter Boas, problem Use equation 1.8 to find a fraction describing Physics 6A Solutios to Homework Set # Witer 0. Boas, problem. 8 Use equatio.8 to fid a fractio describig 0.694444444... Start with the formula S = a, ad otice that we ca remove ay umber of r fiite decimals

More information

Review for Test 3 Math 1552, Integral Calculus Sections 8.8,

Review for Test 3 Math 1552, Integral Calculus Sections 8.8, Review for Test 3 Math 55, Itegral Calculus Sectios 8.8, 0.-0.5. Termiology review: complete the followig statemets. (a) A geometric series has the geeral form k=0 rk.theseriescovergeswhe r is less tha

More information

MA131 - Analysis 1. Workbook 3 Sequences II

MA131 - Analysis 1. Workbook 3 Sequences II MA3 - Aalysis Workbook 3 Sequeces II Autum 2004 Cotets 2.8 Coverget Sequeces........................ 2.9 Algebra of Limits......................... 2 2.0 Further Useful Results........................

More information

2.4 - Sequences and Series

2.4 - Sequences and Series 2.4 - Sequeces ad Series Sequeces A sequece is a ordered list of elemets. Defiitio 1 A sequece is a fuctio from a subset of the set of itegers (usually either the set 80, 1, 2, 3,... < or the set 81, 2,

More information

MA131 - Analysis 1. Workbook 9 Series III

MA131 - Analysis 1. Workbook 9 Series III MA3 - Aalysis Workbook 9 Series III Autum 004 Cotets 4.4 Series with Positive ad Negative Terms.............. 4.5 Alteratig Series.......................... 4.6 Geeral Series.............................

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Lecture 3: Asymptotic Analysis + Recurrences

Lecture 3: Asymptotic Analysis + Recurrences Lecture 3: Asymptotic Aalysis + Recurreces Data Structures ad Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Write a model ad fid Big-O for (it i = 0; i < ; i++) { for (it j = 0; j < i; j++) { System.out.pritl(

More information

Ma 530 Infinite Series I

Ma 530 Infinite Series I Ma 50 Ifiite Series I Please ote that i additio to the material below this lecture icorporated material from the Visual Calculus web site. The material o sequeces is at Visual Sequeces. (To use this li

More information

10.1 Sequences. n term. We will deal a. a n or a n n. ( 1) n ( 1) n 1 2 ( 1) a =, 0 0,,,,, ln n. n an 2. n term.

10.1 Sequences. n term. We will deal a. a n or a n n. ( 1) n ( 1) n 1 2 ( 1) a =, 0 0,,,,, ln n. n an 2. n term. 0. Sequeces A sequece is a list of umbers writte i a defiite order: a, a,, a, a is called the first term, a is the secod term, ad i geeral eclusively with ifiite sequeces ad so each term Notatio: the sequece

More information

Chapter 6. Advanced Counting Techniques

Chapter 6. Advanced Counting Techniques Chapter 6 Advaced Coutig Techiques 6.: Recurrece Relatios Defiitio: A recurrece relatio for the sequece {a } is a equatio expressig a i terms of oe or more of the previous terms of the sequece: a,a2,a3,,a

More information

CSE 5311 Notes 1: Mathematical Preliminaries

CSE 5311 Notes 1: Mathematical Preliminaries Chapter 1 - Algorithms Computig CSE 5311 Notes 1: Mathematical Prelimiaries Last updated 1/20/18 12:56 PM) Relatioship betwee complexity classes, eg log,, log, 2, 2, etc Chapter 2 - Gettig Started Loop

More information

Find a formula for the exponential function whose graph is given , 1 2,16 1, 6

Find a formula for the exponential function whose graph is given , 1 2,16 1, 6 Math 4 Activity (Due by EOC Apr. ) Graph the followig epoetial fuctios by modifyig the graph of f. Fid the rage of each fuctio.. g. g. g 4. g. g 6. g Fid a formula for the epoetial fuctio whose graph is

More information

We are mainly going to be concerned with power series in x, such as. (x)} converges - that is, lims N n

We are mainly going to be concerned with power series in x, such as. (x)} converges - that is, lims N n Review of Power Series, Power Series Solutios A power series i x - a is a ifiite series of the form c (x a) =c +c (x a)+(x a) +... We also call this a power series cetered at a. Ex. (x+) is cetered at

More information

CHAPTER 1 SEQUENCES AND INFINITE SERIES

CHAPTER 1 SEQUENCES AND INFINITE SERIES CHAPTER SEQUENCES AND INFINITE SERIES SEQUENCES AND INFINITE SERIES (0 meetigs) Sequeces ad limit of a sequece Mootoic ad bouded sequece Ifiite series of costat terms Ifiite series of positive terms Alteratig

More information

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem

Lecture 4 Recursive Algorithm Analysis. Merge Sort Solving Recurrences The Master Theorem Lecture 4 Recursive Algorithm Alysis Merge Sort Solvig Recurreces The Mster Theorem Merge Sort MergeSortA, left, right) { if left < right) { mid floorleft right) / 2); MergeSortA, left, mid); MergeSortA,

More information

5 Sequences and Series

5 Sequences and Series Bria E. Veitch 5 Sequeces ad Series 5. Sequeces A sequece is a list of umbers i a defiite order. a is the first term a 2 is the secod term a is the -th term The sequece {a, a 2, a 3,..., a,..., } is a

More information

CHAPTER 10 INFINITE SEQUENCES AND SERIES

CHAPTER 10 INFINITE SEQUENCES AND SERIES CHAPTER 10 INFINITE SEQUENCES AND SERIES 10.1 Sequeces 10.2 Ifiite Series 10.3 The Itegral Tests 10.4 Compariso Tests 10.5 The Ratio ad Root Tests 10.6 Alteratig Series: Absolute ad Coditioal Covergece

More information

n=1 a n is the sequence (s n ) n 1 n=1 a n converges to s. We write a n = s, n=1 n=1 a n

n=1 a n is the sequence (s n ) n 1 n=1 a n converges to s. We write a n = s, n=1 n=1 a n Series. Defiitios ad first properties A series is a ifiite sum a + a + a +..., deoted i short by a. The sequece of partial sums of the series a is the sequece s ) defied by s = a k = a +... + a,. k= Defiitio

More information

Ma 530 Introduction to Power Series

Ma 530 Introduction to Power Series Ma 530 Itroductio to Power Series Please ote that there is material o power series at Visual Calculus. Some of this material was used as part of the presetatio of the topics that follow. What is a Power

More information

INFINITE SEQUENCES AND SERIES

INFINITE SEQUENCES AND SERIES INFINITE SEQUENCES AND SERIES INFINITE SEQUENCES AND SERIES I geeral, it is difficult to fid the exact sum of a series. We were able to accomplish this for geometric series ad the series /[(+)]. This is

More information

Series III. Chapter Alternating Series

Series III. Chapter Alternating Series Chapter 9 Series III With the exceptio of the Null Sequece Test, all the tests for series covergece ad divergece that we have cosidered so far have dealt oly with series of oegative terms. Series with

More information

MA131 - Analysis 1. Workbook 2 Sequences I

MA131 - Analysis 1. Workbook 2 Sequences I MA3 - Aalysis Workbook 2 Sequeces I Autum 203 Cotets 2 Sequeces I 2. Itroductio.............................. 2.2 Icreasig ad Decreasig Sequeces................ 2 2.3 Bouded Sequeces..........................

More information

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2 Shiyao Wag CS:3330 (Prof. Pemmaraju ): Assigmet #1 Solutios Problem 1 (a) Cosider iput with me m 1, m,..., m ad wome w 1, w,..., w with the followig prefereces: All me have the same prefereces for wome:

More information

Series: Infinite Sums

Series: Infinite Sums Series: Ifiite Sums Series are a way to mae sese of certai types of ifiitely log sums. We will eed to be able to do this if we are to attai our goal of approximatig trascedetal fuctios by usig ifiite degree

More information

Section 7 Fundamentals of Sequences and Series

Section 7 Fundamentals of Sequences and Series ectio Fudametals of equeces ad eries. Defiitio ad examples of sequeces A sequece ca be thought of as a ifiite list of umbers. 0, -, -0, -, -0...,,,,,,. (iii),,,,... Defiitio: A sequece is a fuctio which

More information

Part I: Covers Sequence through Series Comparison Tests

Part I: Covers Sequence through Series Comparison Tests Part I: Covers Sequece through Series Compariso Tests. Give a example of each of the followig: (a) A geometric sequece: (b) A alteratig sequece: (c) A sequece that is bouded, but ot coverget: (d) A sequece

More information

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply: Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch AlgoDat Midterm1 Sprig 016 08.04.016 Name: Matriculatio umber: Advice You have

More information

Sequences I. Chapter Introduction

Sequences I. Chapter Introduction Chapter 2 Sequeces I 2. Itroductio A sequece is a list of umbers i a defiite order so that we kow which umber is i the first place, which umber is i the secod place ad, for ay atural umber, we kow which

More information

Sequences. A Sequence is a list of numbers written in order.

Sequences. A Sequence is a list of numbers written in order. Sequeces A Sequece is a list of umbers writte i order. {a, a 2, a 3,... } The sequece may be ifiite. The th term of the sequece is the th umber o the list. O the list above a = st term, a 2 = 2 d term,

More information

Math 113 Exam 3 Practice

Math 113 Exam 3 Practice Math Exam Practice Exam will cover.-.9. This sheet has three sectios. The first sectio will remid you about techiques ad formulas that you should kow. The secod gives a umber of practice questios for you

More information

MATH 31B: MIDTERM 2 REVIEW

MATH 31B: MIDTERM 2 REVIEW MATH 3B: MIDTERM REVIEW JOE HUGHES. Evaluate x (x ) (x 3).. Partial Fractios Solutio: The umerator has degree less tha the deomiator, so we ca use partial fractios. Write x (x ) (x 3) = A x + A (x ) +

More information

Math 155 (Lecture 3)

Math 155 (Lecture 3) Math 55 (Lecture 3) September 8, I this lecture, we ll cosider the aswer to oe of the most basic coutig problems i combiatorics Questio How may ways are there to choose a -elemet subset of the set {,,,

More information

1 Lecture 2: Sequence, Series and power series (8/14/2012)

1 Lecture 2: Sequence, Series and power series (8/14/2012) Summer Jump-Start Program for Aalysis, 202 Sog-Yig Li Lecture 2: Sequece, Series ad power series (8/4/202). More o sequeces Example.. Let {x } ad {y } be two bouded sequeces. Show lim sup (x + y ) lim

More information

The Ratio Test. THEOREM 9.17 Ratio Test Let a n be a series with nonzero terms. 1. a. n converges absolutely if lim. n 1

The Ratio Test. THEOREM 9.17 Ratio Test Let a n be a series with nonzero terms. 1. a. n converges absolutely if lim. n 1 460_0906.qxd //04 :8 PM Page 69 SECTION 9.6 The Ratio ad Root Tests 69 Sectio 9.6 EXPLORATION Writig a Series Oe of the followig coditios guaratees that a series will diverge, two coditios guaratee that

More information

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia) 1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,

More information

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5 CIS 11 Data Structures ad Algorithms with Java Sprig 019 Code Sippets ad Recurreces Moday, February 4/Tuesday, February 5 Learig Goals Practice provig asymptotic bouds with code sippets Practice solvig

More information

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Itroductio to Algorithms 6.046J/8.40J LECTURE 3 Divide ad coquer Biary search Powerig a umber Fiboacci umbers Matrix multiplicatio Strasse s algorithm VLSI tree layout Prof. Charles E. Leiserso The divide-ad-coquer

More information

CS161 Handout 05 Summer 2013 July 10, 2013 Mathematical Terms and Identities

CS161 Handout 05 Summer 2013 July 10, 2013 Mathematical Terms and Identities CS161 Hadout 05 Summer 2013 July 10, 2013 Mathematical Terms ad Idetities Thaks to Ady Nguye ad Julie Tibshirai for their advice o this hadout. This hadout covers mathematical otatio ad idetities that

More information

E. Incorrect! Plug n = 1, 2, 3, & 4 into the general term formula. n =, then the first four terms are found by

E. Incorrect! Plug n = 1, 2, 3, & 4 into the general term formula. n =, then the first four terms are found by Calculus II - Problem Solvig Drill 8: Sequeces, Series, ad Covergece Questio No. of 0. Fid the first four terms of the sequece whose geeral term is give by a ( ) : Questio #0 (A) (B) (C) (D) (E) 8,,, 4

More information

7 Sequences of real numbers

7 Sequences of real numbers 40 7 Sequeces of real umbers 7. Defiitios ad examples Defiitio 7... A sequece of real umbers is a real fuctio whose domai is the set N of atural umbers. Let s : N R be a sequece. The the values of s are

More information

CS / MCS 401 Homework 3 grader solutions

CS / MCS 401 Homework 3 grader solutions CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of

More information

Chapter 4. Fourier Series

Chapter 4. Fourier Series Chapter 4. Fourier Series At this poit we are ready to ow cosider the caoical equatios. Cosider, for eample the heat equatio u t = u, < (4.) subject to u(, ) = si, u(, t) = u(, t) =. (4.) Here,

More information

Data Structures Lecture 9

Data Structures Lecture 9 Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to

More information

Math 25 Solutions to practice problems

Math 25 Solutions to practice problems Math 5: Advaced Calculus UC Davis, Sprig 0 Math 5 Solutios to practice problems Questio For = 0,,, 3,... ad 0 k defie umbers C k C k =! k!( k)! (for k = 0 ad k = we defie C 0 = C = ). by = ( )... ( k +

More information

CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)

CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture) CSI 101 Discrete Structures Witer 01 Prof. Lucia Moura Uiversity of Ottawa Homework Assigmet #4 (100 poits, weight %) Due: Thursday, April, at 1:00pm (i lecture) Program verificatio, Recurrece Relatios

More information

2.4.2 A Theorem About Absolutely Convergent Series

2.4.2 A Theorem About Absolutely Convergent Series 0 Versio of August 27, 200 CHAPTER 2. INFINITE SERIES Add these two series: + 3 2 + 5 + 7 4 + 9 + 6 +... = 3 l 2. (2.20) 2 Sice the reciprocal of each iteger occurs exactly oce i the last series, we would

More information

Problem 4: Evaluate ( k ) by negating (actually un-negating) its upper index. Binomial coefficient

Problem 4: Evaluate ( k ) by negating (actually un-negating) its upper index. Binomial coefficient Problem 4: Evaluate by egatig actually u-egatig its upper idex We ow that Biomial coefficiet r { where r is a real umber, is a iteger The above defiitio ca be recast i terms of factorials i the commo case

More information

Lecture 10: Mathematical Preliminaries

Lecture 10: Mathematical Preliminaries Lecture : Mathematical Prelimiaries Obective: Reviewig mathematical cocepts ad tools that are frequetly used i the aalysis of algorithms. Lecture # Slide # I this

More information

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Data Structures ad Algorithm Xiaoqig Zheg zhegxq@fudaeduc What are algorithms? A sequece of computatioal steps that trasform the iput ito the output Sortig problem: Iput: A sequece of umbers

More information

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES Read Sectio 1.5 (pages 5 9) Overview I Sectio 1.5 we lear to work with summatio otatio ad formulas. We will also itroduce a brief overview of sequeces,

More information

Convergence of random variables. (telegram style notes) P.J.C. Spreij

Convergence of random variables. (telegram style notes) P.J.C. Spreij Covergece of radom variables (telegram style otes).j.c. Spreij this versio: September 6, 2005 Itroductio As we kow, radom variables are by defiitio measurable fuctios o some uderlyig measurable space

More information

It is often useful to approximate complicated functions using simpler ones. We consider the task of approximating a function by a polynomial.

It is often useful to approximate complicated functions using simpler ones. We consider the task of approximating a function by a polynomial. Taylor Polyomials ad Taylor Series It is ofte useful to approximate complicated fuctios usig simpler oes We cosider the task of approximatig a fuctio by a polyomial If f is at least -times differetiable

More information

Advanced Course of Algorithm Design and Analysis

Advanced Course of Algorithm Design and Analysis Differet complexity measures Advaced Course of Algorithm Desig ad Aalysis Asymptotic complexity Big-Oh otatio Properties of O otatio Aalysis of simple algorithms A algorithm may may have differet executio

More information

Analysis of Algorithms. Introduction. Contents

Analysis of Algorithms. Introduction. Contents Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We

More information

MISCELLANEOUS SEQUENCES & SERIES QUESTIONS

MISCELLANEOUS SEQUENCES & SERIES QUESTIONS MISCELLANEOUS SEQUENCES & SERIES QUESTIONS Questio (***+) Evaluate the followig sum 30 r ( 2) 4r 78. 3 MP2-V, 75,822,200 Questio 2 (***+) Three umbers, A, B, C i that order, are i geometric progressio

More information

COMM 602: Digital Signal Processing

COMM 602: Digital Signal Processing COMM 60: Digital Sigal Processig Lecture 4 -Properties of LTIS Usig Z-Trasform -Iverse Z-Trasform Properties of LTIS Usig Z-Trasform Properties of LTIS Usig Z-Trasform -ve +ve Properties of LTIS Usig Z-Trasform

More information

Infinite Sequences and Series

Infinite Sequences and Series Chapter 6 Ifiite Sequeces ad Series 6.1 Ifiite Sequeces 6.1.1 Elemetary Cocepts Simply speakig, a sequece is a ordered list of umbers writte: {a 1, a 2, a 3,...a, a +1,...} where the elemets a i represet

More information

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the

More information

Sequences. Notation. Convergence of a Sequence

Sequences. Notation. Convergence of a Sequence Sequeces A sequece is essetially just a list. Defiitio (Sequece of Real Numbers). A sequece of real umbers is a fuctio Z (, ) R for some real umber. Do t let the descriptio of the domai cofuse you; it

More information

REVIEW 1, MATH n=1 is convergent. (b) Determine whether a n is convergent.

REVIEW 1, MATH n=1 is convergent. (b) Determine whether a n is convergent. REVIEW, MATH 00. Let a = +. a) Determie whether the sequece a ) is coverget. b) Determie whether a is coverget.. Determie whether the series is coverget or diverget. If it is coverget, fid its sum. a)

More information

Midterm Exam #2. Please staple this cover and honor pledge atop your solutions.

Midterm Exam #2. Please staple this cover and honor pledge atop your solutions. Math 50B Itegral Calculus April, 07 Midterm Exam # Name: Aswer Key David Arold Istructios. (00 poits) This exam is ope otes, ope book. This icludes ay supplemetary texts or olie documets. You are ot allowed

More information

Math 2784 (or 2794W) University of Connecticut

Math 2784 (or 2794W) University of Connecticut ORDERS OF GROWTH PAT SMITH Math 2784 (or 2794W) Uiversity of Coecticut Date: Mar. 2, 22. ORDERS OF GROWTH. Itroductio Gaiig a ituitive feel for the relative growth of fuctios is importat if you really

More information

Sigma notation. 2.1 Introduction

Sigma notation. 2.1 Introduction Sigma otatio. Itroductio We use sigma otatio to idicate the summatio process whe we have several (or ifiitely may) terms to add up. You may have see sigma otatio i earlier courses. It is used to idicate

More information

1 Generating functions for balls in boxes

1 Generating functions for balls in boxes Math 566 Fall 05 Some otes o geeratig fuctios Give a sequece a 0, a, a,..., a,..., a geeratig fuctio some way of represetig the sequece as a fuctio. There are may ways to do this, with the most commo ways

More information

SEQUENCES AND SERIES

SEQUENCES AND SERIES Sequeces ad 6 Sequeces Ad SEQUENCES AND SERIES Successio of umbers of which oe umber is desigated as the first, other as the secod, aother as the third ad so o gives rise to what is called a sequece. Sequeces

More information

k-generalized FIBONACCI NUMBERS CLOSE TO THE FORM 2 a + 3 b + 5 c 1. Introduction

k-generalized FIBONACCI NUMBERS CLOSE TO THE FORM 2 a + 3 b + 5 c 1. Introduction Acta Math. Uiv. Comeiaae Vol. LXXXVI, 2 (2017), pp. 279 286 279 k-generalized FIBONACCI NUMBERS CLOSE TO THE FORM 2 a + 3 b + 5 c N. IRMAK ad M. ALP Abstract. The k-geeralized Fiboacci sequece { F (k)

More information

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials. Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem

More information

Chapter 2. Asymptotic Notation

Chapter 2. Asymptotic Notation Asyptotic Notatio 3 Chapter Asyptotic Notatio Goal : To siplify the aalysis of ruig tie by gettig rid of details which ay be affected by specific ipleetatio ad hardware. [1] The Big Oh (O-Notatio) : It

More information

4.1 Sigma Notation and Riemann Sums

4.1 Sigma Notation and Riemann Sums 0 the itegral. Sigma Notatio ad Riema Sums Oe strategy for calculatig the area of a regio is to cut the regio ito simple shapes, calculate the area of each simple shape, ad the add these smaller areas

More information

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication Next. Covered bsics of simple desig techique (Divided-coquer) Ch. of the text.. Next, Strsse s lgorithm. Lter: more desig d coquer lgorithms: MergeSort. Solvig recurreces d the Mster Theorem. Similr ide

More information

COMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro

COMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro COMP60: Itroduig Complexity Aalysis (08/9) Luas Cordeiro luas.ordeiro@mahester.a.uk Itroduig Complexity Aalysis Textbook: Algorithm Desig ad Appliatios, Goodrih, Mihael T. ad Roberto Tamassia (hapter )

More information

MATH 10550, EXAM 3 SOLUTIONS

MATH 10550, EXAM 3 SOLUTIONS MATH 155, EXAM 3 SOLUTIONS 1. I fidig a approximate solutio to the equatio x 3 +x 4 = usig Newto s method with iitial approximatio x 1 = 1, what is x? Solutio. Recall that x +1 = x f(x ) f (x ). Hece,

More information

CS166 Handout 02 Spring 2018 April 3, 2018 Mathematical Terms and Identities

CS166 Handout 02 Spring 2018 April 3, 2018 Mathematical Terms and Identities CS166 Hadout 02 Sprig 2018 April 3, 2018 Mathematical Terms ad Idetities Thaks to Ady Nguye ad Julie Tibshirai for their advice o this hadout. This hadout covers mathematical otatio ad idetities that may

More information

6.3 Testing Series With Positive Terms

6.3 Testing Series With Positive Terms 6.3. TESTING SERIES WITH POSITIVE TERMS 307 6.3 Testig Series With Positive Terms 6.3. Review of what is kow up to ow I theory, testig a series a i for covergece amouts to fidig the i= sequece of partial

More information

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2 Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.

More information

JANE PROFESSOR WW Prob Lib1 Summer 2000

JANE PROFESSOR WW Prob Lib1 Summer 2000 JANE PROFESSOR WW Prob Lib Summer 000 Sample WeBWorK problems. WeBWorK assigmet Series6CompTests due /6/06 at :00 AM..( pt) Test each of the followig series for covergece by either the Compariso Test or

More information

Read carefully the instructions on the answer book and make sure that the particulars required are entered on each answer book.

Read carefully the instructions on the answer book and make sure that the particulars required are entered on each answer book. THE UNIVERSITY OF WARWICK FIRST YEAR EXAMINATION: Jauary 2009 Aalysis I Time Allowed:.5 hours Read carefully the istructios o the aswer book ad make sure that the particulars required are etered o each

More information

Created by T. Madas SERIES. Created by T. Madas

Created by T. Madas SERIES. Created by T. Madas SERIES SUMMATIONS BY STANDARD RESULTS Questio (**) Use stadard results o summatios to fid the value of 48 ( r )( 3r ). 36 FP-B, 66638 Questio (**+) Fid, i fully simplified factorized form, a expressio

More information