Improving The Problem Not the Code

Size: px
Start display at page:

Download "Improving The Problem Not the Code"

Transcription

1 mprovig Te Probem Not te Code

2 Fidig Te Max ad Mi of a Number Comparig two adjacet umbers ad fidig te maximum ad miimum e.g Normay T()= N- Compariso wit a orace, i tis case a touramet teory N-1 matces are ecessary & sufficiet to fid a wier i a touramet of payers Miimum as to be amog tose wo as ost first matc, so we ca use osers of first compariso ad try to miimize tis set of umbers. Te oser set wi at east cosist of N/ umbers if we pay pair wise, so i tat case tota wi be N/+(N/-1)+(N/-1)=3N/- stead of improvig te code we wet ito te costructio of te probem. t is to be soved by dividig te umbers ito two sets we takig iput of two umbers eac.

3 Fidig max & extmax Secod argest must ecessariy oose from te argest. So secod argest must b foud from tose wo were compared & ost from te argest, ad te set of suc umber soud be miimized. Te egt of te pat of te wier wi give umber of compared eemets wit te wier. Storig umbers from to

4 Towers of Haoi At ay time smaer disk soud ot be beow te arger disk Oy disk 1 disk case 3 disk case <a,b> <a,c>,<a,b><c,b> <a,c><a,b><c,a><b,c><a,c><a,b><c,a><c,b><a,b> <a,b><a,c><b,c><a,b><c,a><c,b><a,b> 3(a,b,c) (a,c,b,) (1,a,b,c) (,c,b,a) Base: (==1) L=<a,b> ductio: (>1) 1=towers(-1,a,c,b) =towers(1,a,b,c) 3=towers(-1,c,b,a)

5 Fidig Greatest Commo Divisor put: Two iteger s m a Output: Greatest factor tat divides bot 1. Factorize m: fid primes m1, m, m3 suc tat m= m1*m*m3. Factorize : fid primes 1,, 3 suc tat = 1**3 3. Fid commo factors i bot mutipy ad prit resut Additioa Beefits: we ad foud prime umbers aso o te sides

6 Eucid Agoritm t is usig a cever tecique wic was expored after studyig te deeper properties of te umbers ivoved. 1 divide m by ad et r be te remaider if r=0, agoritm termiates; is te aswer 3 set m=; =r; ad go to step 1

7 Agoritm witout swappig 1 divide m by ad et r be te remaider if r=0, agoritm termiates; is te aswer 3 divide by r ad et m be te remaider 4 if m=0, agoritm termiates; r is te aswer 5 divide r by m ad et be te remaider 6 if =0, agoritm termiates; m is te aswer 7. go to step 1

8 Agoritm witout additioa variabe 1. Divide m by ad et m be te remaider. f m=0, te agoritm termiates wit aswer 3. Divide by m ad et be te remaider 4. if =0 te agoritm termiates wit aswer m; oterwise go to step 1

9 f we go deeper te et m=ag ad =bg aso m=x*+r T(a, b) = 1 + T(b, r 0 ) = + T(r 0, r 1 ) = = N + T(r N, r N 1 ) = N + 1 f te Eucidea agoritm requires N steps for a pair of atura umbers a > b > 0, te smaest vaues of a ad b for wic tis is true are te Fiboacci umbers F N+ ad F N+1, respectivey. Worst-case umber of steps By iductio. f N = 1, b divides a wit o remaider; te smaest atura umbers for wic tis is true is b = 1 ad a =, wic are F ad F 3, respectivey.

10 Now assume tat te resut ods for a vaues of N up to M 1. Te first step of te M-step agoritm is a = q 0 b + r 0, ad te secod step is b = q 1 r 0 + r 1. Sice te agoritm is recursive, it required M 1 steps to fid GCD(b, r 0 ) ad teir smaest vaues are F M+1 ad F M. Te smaest vaue of a is terefore we q 0 = 1, wic gives a = b + r 0 = F M+1 + F M = F M+. For N steps, te b is greater ta or equa to F N+1 wic i tur is greater ta or equa to φ N 1, were φ is te gode ratio. Sice b φ N 1, te N 1 og φ b. Sice og 10 φ > 1/5, (N 1)/5 < og 10 φ og φ b = og 10 b. Tus, N 5 og 10 b. Tus, te Eucidea agoritm aways eeds ess ta O() divisios, were is te umber of digits i te smaer umber b.

11 Recursio Discussio o differet pases of ay recursio agoritm maiy Base coditio, Decompositio ad recompositio. Aso ow recursio may be usefu i makig te code sorter ad simper, but i some cases it may prove very costy. Exampe of fiboacci sequece ike fib(6) breakig ito fib(5),fib(4) ad so o ad makig te umber of fuctio cas of te expoetia order. Wie te iterative fiboacci sequece wi be of te order of O(). Fiboacci sequece ca aso be soved i og time by recursive squarig metod F+1 F = F F = x x is to fid te t fiboacci umber t is θ(og) F F-1 F-1 F- 1 0

12

13

14

15 Substitutio Metod 1. Guess te form of te soutio. Verify by iductio ad sow tat te soutio works for a set of costats T()=T(/) + Wic meas tat ow te probem as bee divided ito two sub probems ad size of te sub probem is / We guess tat it works for T() = O( g ) To prove tat T() c g for a appropriate c. Assumig tat te guess works we wi ave T() = ( c (/) g (/))+ = c g(/) + = c g c g + = c g (c-1) cg tis is true for a c 1

16

17 Tota = + (3/16) + (3/16) k /16 k +. Tis is a geometric series (1/1-(3/16)) θ( )

18 Master Metod T()= at(/b) + f() : Were a 1 ad b>1 are costats ad f() is a asymptoticay positive fuctio We are dividig a probem of size ito a sub probems, eac of size /b, were a ad b are positive costats. a sub probems are soved recursivey eac i time T(/b) were a ad b are positive costats. Te cost of dividig te probem ad combiig te resuts of te sub probems is described by te fuctio f(). 1. f F() = O( og b a -ε )for some costat ε > 0, te T() = θ ( og b a ). f, f() = θ ( og b a og k )te. T()= θ( og b a og k+1 ) 3. f f()=ω( og b a+ ε ) for some costat ε > 0, ad if a f (/b) cf () for some costat c < 1 ad a sufficiety arge, te T () = Θ(f ())

19 Tree cases do ot cover a te possibiities for f (). Tere is a gap betwee cases 1 ad we f () is smaer ta but ot poyomiay smaer. Simiary, tere is a gap betwee cases ad 3 we f () is arger ta but ot poyomiay arger. f te fuctio f () fas ito oe of tese gaps, or if te reguarity coditio i case 3 fais to od, te master metod caot be used T() = 4T(/) + og b a = wic is poyomiay arger te f() so we are i case 1 ad aswer is θ( ) T() = 4T(/) + og b a = wic is same simiar to f() so we are i case ad aswer is θ( og) T() = 4T(/) + 3 og b a = wic is poyomiay arger from f() so we are i case 3 ad aswer is θ( 3 ) T()=T(/)+og case O(og ) T() = 4T(/) + / og Master metod does ot appy Biary Searc T() = 1.T(/) + O(1)= θ(og) Fidig Powers of a umber T()= T(/)+ θ(1) = θ(og)

20 Case1: Te Weigt icreases Geometricay from te root to te eaves. Te eaves od a costat fractio of te tota weigt. Last term is domiatig. Case : for k=0 weigt is approximatey same o a eves. t is poyomia or sowy decreasig fuctio. Case 3: Te Weigt decreases Geometricay from te root to te eaves. Te root od a costat fractio of te tota weigt. First term is domiatig.

21 teger mutipicatio How fast we ca mutipy Normay we require compexity to mutipy two umbers Mutipy two -bit itegers ad. Divide step: Spit ad ito ig-order ad ow-order bits / / We ca te defie * by mutipyig te parts ad addig: / / / / ) )*( ( * So, T() = 4T(/) +, wic impies T() is O( ). But tat is o better

22 / / / / ) )*( ( * / / / ) ( ] ) [( ] ) )( [( * So, T() = 3T(/) +, wic impies T() is O( og 3 ), by te Master Teorem. Tus, T() is O( ).

23 Matrix Mutipicatio Suppose we wat to mutipy two matrices of size N x N: for exampe A x B = C. C 11 = a 11 b 11 + a 1 b 1 C 1 = a 11 b 1 + a 1 b C 1 = a 1 b 11 + a b 1 C = a 1 b 1 + a b x matrix mutipicatio ca be accompised i 8 mutipicatio. T()= 8T(/) + = ( og 8 = 3 ) Strasse sowed tat x matrix mutipicatio ca be accompised i 7 mutipicatio ad 18 additios or subtractios.

24 T() = 7T(/) + = ( og 7 =.807 ) Tis reductio ca be doe by Divide ad Coquer Approac Divide matrices ito sub-matrices: A 0, A 1, A etc Use bocked matrix mutipy equatios Recursivey mutipy sub-matrices Termiate recursio wit a simpe base case P1 = (A11+ A)(B11+B) P = (A1 + A) * B11 P3 = A11 * (B1 - B) P4 = A * (B1 - B11) P5 = (A11 + A1) * B P6 = (A1 - A11) * (B11 + B1) P7 = (A1 - A) * (B1 + B) C11 = P1 + P4 - P5 + P7 C1 = P3 + P5 C1 = P + P4 C = P1 + P3 - P + P6 C 11 = P 1 + P 4 - P 5 + P 7 = (A 11 + A )(B 11 +B ) + A * (B 1 - B 11 ) - (A 11 + A 1 ) * B +(A 1 - A ) * (B 1 + B ) = A 11 B 11 + A 11 B + A B 11 + A B + A B 1 A B 11 -A 11 B -A 1 B +A 1 B 1 + A 1 B A B 1 A B = A 11 B 11 + A 1 B 1 Strasse beats orma matrix mutipicatio for 5 approx.

25 fiite Wa Probem * You ave a ifiite wa o bot sides were you are stadig ad it as a gate somewere i oe directio, you ave to fid out te gate, o desig-ifiite time icremeta desig- you go oe step i oe directio, come back go to oter directio oe step, come back ad te go steps i oter directio : : -1+.(-1) i+3 4(-1)/+3= +

26 Usig Divide ad Coquer You go 0 step i oe directio, come back go 1 step i oter te 1 directio i oe way te come back ad te up to k : K-1 +. K-1 + K-1 3. K : 4( K-1 + K- + 1)+ 3. K 4( K -1)+ 3. K 7. K -4 7N-4

Divide-and-Conquer. Divide-and-Conquer 1

Divide-and-Conquer. Divide-and-Conquer 1 Divide-d-Coquer 7 9 4 4 7 9 7 7 9 4 4 9 7 7 9 9 4 4 Divide-d-Coquer 1 Outie d Redig Divide-d-coquer prdigm 5. Review Merge-sort 4.1.1 Recurrece Equtios 5..1 tertive sustitutio Recursio trees Guess-d-test

More information

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

3sin A 1 2sin B. 3π x is a solution. 1. If A and B are acute positive angles satisfying the equation 3sin A 2sin B 1 and 3sin 2A 2sin 2B 0, then A 2B

3sin A 1 2sin B. 3π x is a solution. 1. If A and B are acute positive angles satisfying the equation 3sin A 2sin B 1 and 3sin 2A 2sin 2B 0, then A 2B 1. If A ad B are acute positive agles satisfyig the equatio 3si A si B 1 ad 3si A si B 0, the A B (a) (b) (c) (d) 6. 3 si A + si B = 1 3si A 1 si B 3 si A = cosb Also 3 si A si B = 0 si B = 3 si A Now,

More information

ALLOCATING SAMPLE TO STRATA PROPORTIONAL TO AGGREGATE MEASURE OF SIZE WITH BOTH UPPER AND LOWER BOUNDS ON THE NUMBER OF UNITS IN EACH STRATUM

ALLOCATING SAMPLE TO STRATA PROPORTIONAL TO AGGREGATE MEASURE OF SIZE WITH BOTH UPPER AND LOWER BOUNDS ON THE NUMBER OF UNITS IN EACH STRATUM ALLOCATING SAPLE TO STRATA PROPORTIONAL TO AGGREGATE EASURE OF SIZE WIT BOT UPPER AND LOWER BOUNDS ON TE NUBER OF UNITS IN EAC STRATU Lawrece R. Erst ad Cristoper J. Guciardo Erst_L@bls.gov, Guciardo_C@bls.gov

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

LIMITS AND DERIVATIVES

LIMITS AND DERIVATIVES Capter LIMITS AND DERIVATIVES. Overview.. Limits of a fuctio Let f be a fuctio defied i a domai wic we take to be a iterval, say, I. We sall study te cocept of it of f at a poit a i I. We say f ( ) is

More information

LIMITS AND DERIVATIVES NCERT

LIMITS AND DERIVATIVES NCERT . Overview.. Limits of a fuctio Let f be a fuctio defied i a domai wic we take to be a iterval, say, I. We sall study te cocept of it of f at a poit a i I. We say f ( ) is te epected value of f at a give

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

Solutions to Math 347 Practice Problems for the final

Solutions to Math 347 Practice Problems for the final Solutios to Math 347 Practice Problems for the fial 1) True or False: a) There exist itegers x,y such that 50x + 76y = 6. True: the gcd of 50 ad 76 is, ad 6 is a multiple of. b) The ifiimum of a set is

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

CHAPTER 11 Limits and an Introduction to Calculus

CHAPTER 11 Limits and an Introduction to Calculus CHAPTER Limits ad a Itroductio to Calculus Sectio. Itroductio to Limits................... 50 Sectio. Teciques for Evaluatig Limits............. 5 Sectio. Te Taget Lie Problem................. 50 Sectio.

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

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

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

Lecture 7 Testing Nonlinear Inequality Restrictions 1

Lecture 7 Testing Nonlinear Inequality Restrictions 1 Eco 75 Lecture 7 Testig Noliear Iequality Restrictios I Lecture 6, we discussed te testig problems were te ull ypotesis is de ed by oliear equality restrictios: H : ( ) = versus H : ( ) 6= : () We sowed

More information

University of Washington Department of Chemistry Chemistry 453 Winter Quarter 2015

University of Washington Department of Chemistry Chemistry 453 Winter Quarter 2015 Uiversity of Wasigto Departmet of Cemistry Cemistry 453 Witer Quarter 15 Lecture 14. /11/15 Recommeded Text Readig: Atkis DePaula: 9.1, 9., 9.3 A. Te Equipartitio Priciple & Eergy Quatizatio Te Equipartio

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

Strauss PDEs 2e: Section Exercise 4 Page 1 of 5. u tt = c 2 u xx ru t for 0 < x < l u = 0 at both ends u(x, 0) = φ(x) u t (x, 0) = ψ(x),

Strauss PDEs 2e: Section Exercise 4 Page 1 of 5. u tt = c 2 u xx ru t for 0 < x < l u = 0 at both ends u(x, 0) = φ(x) u t (x, 0) = ψ(x), Strauss PDEs e: Sectio 4.1 - Exercise 4 Page 1 of 5 Exercise 4 Cosider waves i a resistat medium that satisfy the probem u tt = c u xx ru t for < x < u = at both eds ux, ) = φx) u t x, ) = ψx), where r

More information

Minimizing Makespan on Parallel Machines with Machine Eligibility Restrictions

Minimizing Makespan on Parallel Machines with Machine Eligibility Restrictions 18 Te Ope Operatioa Researc Joura, 2008, 2, 18-24 Miimizig Makespa o Parae Macies wit Macie Eigibiity Restrictios Cie-Hug Li 1 ad Cig-Jog Liao *,2 1 Jiwe Uiversity of Sciece ad Tecoogy, Taipei Couty, Taiwa

More information

Sums, products and sequences

Sums, products and sequences Sums, products ad sequeces How to write log sums, e.g., 1+2+ (-1)+ cocisely? i=1 Sum otatio ( sum from 1 to ): i 3 = 1 + 2 + + If =3, i=1 i = 1+2+3=6. The ame ii does ot matter. Could use aother letter

More information

LECTURE 2 LEAST SQUARES CROSS-VALIDATION FOR KERNEL DENSITY ESTIMATION

LECTURE 2 LEAST SQUARES CROSS-VALIDATION FOR KERNEL DENSITY ESTIMATION Jauary 3 07 LECTURE LEAST SQUARES CROSS-VALIDATION FOR ERNEL DENSITY ESTIMATION Noparametric kerel estimatio is extremely sesitive to te coice of badwidt as larger values of result i averagig over more

More information

Algorithms Design & Analysis. Divide & Conquer

Algorithms Design & Analysis. Divide & Conquer Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised

More information

In algebra one spends much time finding common denominators and thus simplifying rational expressions. For example:

In algebra one spends much time finding common denominators and thus simplifying rational expressions. For example: 74 The Method of Partial Fractios I algebra oe speds much time fidig commo deomiators ad thus simplifyig ratioal epressios For eample: + + + 6 5 + = + = = + + + + + ( )( ) 5 It may the seem odd to be watig

More information

Complex Numbers Solutions

Complex Numbers Solutions Complex Numbers Solutios Joseph Zoller February 7, 06 Solutios. (009 AIME I Problem ) There is a complex umber with imagiary part 64 ad a positive iteger such that Fid. [Solutio: 697] 4i + + 4i. 4i 4i

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

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

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

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

Symbolic computation 2: Linear recurrences

Symbolic computation 2: Linear recurrences Bachelor of Ecole Polytechique Computatioal Mathematics, year 2, semester Lecturer: Lucas Geri (sed mail) (mailto:lucas.geri@polytechique.edu) Symbolic computatio 2: Liear recurreces Table of cotets Warm-up

More information

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer

Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, Divide-and-Conquer Presettio or use wit te textook, Agoritm Desig Appictios, y M. T. Gooric R. Tmssi, Wiey, 015 Divie--Coquer 015 Gooric Tmssi Divie--Coquer 1 Appictio: Mxim Sets We c visuize te vrious tre-os or optimizig

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

[ 11 ] z of degree 2 as both degree 2 each. The degree of a polynomial in n variables is the maximum of the degrees of its terms.

[ 11 ] z of degree 2 as both degree 2 each. The degree of a polynomial in n variables is the maximum of the degrees of its terms. [ 11 ] 1 1.1 Polyomial Fuctios 1 Algebra Ay fuctio f ( x) ax a1x... a1x a0 is a polyomial fuctio if ai ( i 0,1,,,..., ) is a costat which belogs to the set of real umbers ad the idices,, 1,...,1 are atural

More information

Chapter 10: Power Series

Chapter 10: Power Series Chapter : Power Series 57 Chapter Overview: Power Series The reaso series are part of a Calculus course is that there are fuctios which caot be itegrated. All power series, though, ca be itegrated because

More information

x x x 2x x N ( ) p NUMERICAL METHODS UNIT-I-SOLUTION OF EQUATIONS AND EIGENVALUE PROBLEMS By Newton-Raphson formula

x x x 2x x N ( ) p NUMERICAL METHODS UNIT-I-SOLUTION OF EQUATIONS AND EIGENVALUE PROBLEMS By Newton-Raphson formula NUMERICAL METHODS UNIT-I-SOLUTION OF EQUATIONS AND EIGENVALUE PROBLEMS. If g( is cotiuous i [a,b], te uder wat coditio te iterative (or iteratio metod = g( as a uique solutio i [a,b]? '( i [a,b].. Wat

More information

Theory and implementation behind: Universal surface creation - smallest unitcell

Theory and implementation behind: Universal surface creation - smallest unitcell Teory and impementation beind: Universa surface creation - smaest unitce Bjare Brin Buus, Jaob Howat & Tomas Bigaard September 15, 218 1 Construction of surface sabs Te aim for tis part of te project is

More information

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

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T.

More information

Exam 2 CMSC 203 Fall 2009 Name SOLUTION KEY Show All Work! 1. (16 points) Circle T if the corresponding statement is True or F if it is False.

Exam 2 CMSC 203 Fall 2009 Name SOLUTION KEY Show All Work! 1. (16 points) Circle T if the corresponding statement is True or F if it is False. 1 (1 poits) Circle T if the correspodig statemet is True or F if it is False T F For ay positive iteger,, GCD(, 1) = 1 T F Every positive iteger is either prime or composite T F If a b mod p, the (a/p)

More information

Properties and Tests of Zeros of Polynomial Functions

Properties and Tests of Zeros of Polynomial Functions Properties ad Tests of Zeros of Polyomial Fuctios The Remaider ad Factor Theorems: Sythetic divisio ca be used to fid the values of polyomials i a sometimes easier way tha substitutio. This is show by

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

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

Partial Differential Equations

Partial Differential Equations EE 84 Matematical Metods i Egieerig Partial Differetial Eqatios Followig are some classical partial differetial eqatios were is assmed to be a fctio of two or more variables t (time) ad y (spatial coordiates).

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

The Advection-Diffusion equation!

The Advection-Diffusion equation! ttp://www.d.edu/~gtryggva/cf-course/! Te Advectio-iffusio equatio! Grétar Tryggvaso! Sprig 3! Navier-Stokes equatios! Summary! u t + u u x + v u y = P ρ x + µ u + u ρ y Hyperbolic part! u x + v y = Elliptic

More information

Discrete Fourier Transform

Discrete Fourier Transform Discrete Fourier Trasform ) Purpose The purpose is to represet a determiistic or stochastic siga u( t ) as a fiite Fourier sum, whe observatios of u() t ( ) are give o a reguar grid, each affected by a

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

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece,, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet as

More information

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence Sequeces A sequece of umbers is a fuctio whose domai is the positive itegers. We ca see that the sequece 1, 1, 2, 2, 3, 3,... is a fuctio from the positive itegers whe we write the first sequece elemet

More information

Math 113 Exam 3 Practice

Math 113 Exam 3 Practice Math Exam Practice Exam 4 will cover.-., 0. ad 0.. Note that eve though. was tested i exam, questios from that sectios may also be o this exam. For practice problems o., refer to the last review. This

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

Here are some solutions to the sample problems concerning series solution of differential equations with non-constant coefficients (Chapter 12).

Here are some solutions to the sample problems concerning series solution of differential equations with non-constant coefficients (Chapter 12). Lecture Appedi B: Some sampe probems from Boas Here are some soutios to the sampe probems cocerig series soutio of differetia equatios with o-costat coefficiets (Chapter ) : Soutio: We wat to cosider the

More information

Differentiation Techniques 1: Power, Constant Multiple, Sum and Difference Rules

Differentiation Techniques 1: Power, Constant Multiple, Sum and Difference Rules Differetiatio Teciques : Power, Costat Multiple, Sum ad Differece Rules 97 Differetiatio Teciques : Power, Costat Multiple, Sum ad Differece Rules Model : Fidig te Equatio of f '() from a Grap of f ()

More information

Atomic Physics 4. Name: Date: 1. The de Broglie wavelength associated with a car moving with a speed of 20 m s 1 is of the order of. A m.

Atomic Physics 4. Name: Date: 1. The de Broglie wavelength associated with a car moving with a speed of 20 m s 1 is of the order of. A m. Name: Date: Atomic Pysics 4 1. Te de Broglie wavelegt associated wit a car movig wit a speed of 0 m s 1 is of te order of A. 10 38 m. B. 10 4 m. C. 10 4 m. D. 10 38 m.. Te diagram below sows tree eergy

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

In number theory we will generally be working with integers, though occasionally fractions and irrationals will come into play.

In number theory we will generally be working with integers, though occasionally fractions and irrationals will come into play. Number Theory Math 5840 otes. Sectio 1: Axioms. I umber theory we will geerally be workig with itegers, though occasioally fractios ad irratioals will come ito play. Notatio: Z deotes the set of all itegers

More information

MATH 324 Summer 2006 Elementary Number Theory Solutions to Assignment 2 Due: Thursday July 27, 2006

MATH 324 Summer 2006 Elementary Number Theory Solutions to Assignment 2 Due: Thursday July 27, 2006 MATH 34 Summer 006 Elemetary Number Theory Solutios to Assigmet Due: Thursday July 7, 006 Departmet of Mathematical ad Statistical Scieces Uiversity of Alberta Questio [p 74 #6] Show that o iteger of the

More information

PROPERTIES OF THE POSITIVE INTEGERS

PROPERTIES OF THE POSITIVE INTEGERS PROPERTIES OF THE POSITIVE ITEGERS The first itroductio to mathematics occurs at the pre-school level ad cosists of essetially coutig out the first te itegers with oe s figers. This allows the idividuals

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

Lesson 10: Limits and Continuity

Lesson 10: Limits and Continuity www.scimsacademy.com Lesso 10: Limits ad Cotiuity SCIMS Academy 1 Limit of a fuctio The cocept of limit of a fuctio is cetral to all other cocepts i calculus (like cotiuity, derivative, defiite itegrals

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

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

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

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

LIMITS MULTIPLE CHOICE QUESTIONS. (a) 1 (b) 0 (c) 1 (d) does not exist. (a) 0 (b) 1/4 (c) 1/2 (d) 1/8. (a) 1 (b) e (c) 0 (d) none of these

LIMITS MULTIPLE CHOICE QUESTIONS. (a) 1 (b) 0 (c) 1 (d) does not exist. (a) 0 (b) 1/4 (c) 1/2 (d) 1/8. (a) 1 (b) e (c) 0 (d) none of these DSHA CLASSES Guidig you to Success LMTS MULTPLE CHOCE QUESTONS.... 5. Te value of + LEVEL (Objective Questios) (a) e (b) e (c) e 5 (d) e 5 (a) (b) (c) (d) does ot et (a) (b) / (c) / (d) /8 (a) (b) (c)

More information

Math 106 Fall 2014 Exam 3.1 December 10, 2014

Math 106 Fall 2014 Exam 3.1 December 10, 2014 Math 06 Fall 0 Exam 3 December 0, 0 Determie if the series is coverget or diverget by makig a compariso DCT or LCT) with a suitable b Fill i the blaks with your aswer For Coverget or Diverget write Coverget

More information

Zeros of Polynomials

Zeros of Polynomials Math 160 www.timetodare.com 4.5 4.6 Zeros of Polyomials I these sectios we will study polyomials algebraically. Most of our work will be cocered with fidig the solutios of polyomial equatios of ay degree

More information

sin(n) + 2 cos(2n) n 3/2 3 sin(n) 2cos(2n) n 3/2 a n =

sin(n) + 2 cos(2n) n 3/2 3 sin(n) 2cos(2n) n 3/2 a n = 60. Ratio ad root tests 60.1. Absolutely coverget series. Defiitio 13. (Absolute covergece) A series a is called absolutely coverget if the series of absolute values a is coverget. The absolute covergece

More information

x x x Using a second Taylor polynomial with remainder, find the best constant C so that for x 0,

x x x Using a second Taylor polynomial with remainder, find the best constant C so that for x 0, Math Activity 9( Due with Fial Eam) Usig first ad secod Taylor polyomials with remaider, show that for, 8 Usig a secod Taylor polyomial with remaider, fid the best costat C so that for, C 9 The th Derivative

More information

Continuity and Differentiability Worksheet

Continuity and Differentiability Worksheet Continuity and Differentiability Workseet (Be sure tat you can also do te grapical eercises from te tet- Tese were not included below! Typical problems are like problems -3, p. 6; -3, p. 7; 33-34, p. 7;

More information

Test One (Answer Key)

Test One (Answer Key) CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)

More information

MAT1026 Calculus II Basic Convergence Tests for Series

MAT1026 Calculus II Basic Convergence Tests for Series MAT026 Calculus II Basic Covergece Tests for Series Egi MERMUT 202.03.08 Dokuz Eylül Uiversity Faculty of Sciece Departmet of Mathematics İzmir/TURKEY Cotets Mootoe Covergece Theorem 2 2 Series of Real

More information

Number Representation

Number Representation Number Represetatio 1 Number System :: The Basics We are accustomed to usig the so-called decimal umber system Te digits :: 0,1,2,3,4,5,6,7,8,9 Every digit positio has a weight which is a power of 10 Base

More information

MSM203a: Polynomials and rings Chapter 3: Integral domains and fields

MSM203a: Polynomials and rings Chapter 3: Integral domains and fields MSM203a: Poyomias ad rigs Chapter 3: Itegra domais ad fieds Richard Kaye Autum 2013 Note: These prited hadouts are iteded to suppemet the materia provided i ectures. They are ot sufficiet o their ow. This

More information

Different kinds of Mathematical Induction

Different kinds of Mathematical Induction Differet ids of Mathematical Iductio () Mathematical Iductio Give A N, [ A (a A a A)] A N () (First) Priciple of Mathematical Iductio Let P() be a propositio (ope setece), if we put A { : N p() is true}

More information

Math 106 Fall 2014 Exam 3.2 December 10, 2014

Math 106 Fall 2014 Exam 3.2 December 10, 2014 Math 06 Fall 04 Exam 3 December 0, 04 Determie if the series is coverget or diverget by makig a compariso (DCT or LCT) with a suitable b Fill i the blaks with your aswer For Coverget or Diverget write

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

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

NODIA AND COMPANY. Model Test Paper - I GATE Signal & System. Copyright By Publishers

NODIA AND COMPANY. Model Test Paper - I GATE Signal & System. Copyright By Publishers No part of tis pubicatio may be reproduced or distributed i ay form or ay meas, eectroic, mecaica, potocopyig, or oterwise witout te prior permissio of te autor. Mode Test Paper I GATE Copyrigt By Pubisers

More information

+ au n+1 + bu n = 0.)

+ au n+1 + bu n = 0.) Lecture 6 Recurreces - kth order: u +k + a u +k +... a k u k 0 where a... a k are give costats, u 0... u k are startig coditios. (Simple case: u + au + + bu 0.) How to solve explicitly - first, write characteristic

More information

Online Appendix. to Add-on Policies under Vertical Differentiation: Why Do Luxury Hotels Charge for Internet While Economy Hotels Do Not?

Online Appendix. to Add-on Policies under Vertical Differentiation: Why Do Luxury Hotels Charge for Internet While Economy Hotels Do Not? Onine Appendix to Add-on Poicies under Vertica Differentiation: Wy Do Luxury Hotes Carge for Internet Wie Economy Hotes Do Not? Song Lin Department of Marketing, Hong Kong University of Science and Tecnoogy

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

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

Stability analysis of numerical methods for stochastic systems with additive noise

Stability analysis of numerical methods for stochastic systems with additive noise Stability aalysis of umerical metods for stoctic systems wit additive oise Yosiiro SAITO Abstract Stoctic differetial equatios (SDEs) represet pysical peomea domiated by stoctic processes As for determiistic

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

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

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs CSE 1400 Applied Discrete Mathematics Number Theory ad Proofs Departmet of Computer Scieces College of Egieerig Florida Tech Sprig 01 Problems for Number Theory Backgroud Number theory is the brach of

More information

Chapter 6 Overview: Sequences and Numerical Series. For the purposes of AP, this topic is broken into four basic subtopics:

Chapter 6 Overview: Sequences and Numerical Series. For the purposes of AP, this topic is broken into four basic subtopics: Chapter 6 Overview: Sequeces ad Numerical Series I most texts, the topic of sequeces ad series appears, at first, to be a side topic. There are almost o derivatives or itegrals (which is what most studets

More information

Improved Estimation of Rare Sensitive Attribute in a Stratified Sampling Using Poisson Distribution

Improved Estimation of Rare Sensitive Attribute in a Stratified Sampling Using Poisson Distribution Ope Joural of Statistics, 06, 6, 85-95 Publised Olie February 06 i SciRes ttp://wwwscirporg/joural/ojs ttp://dxdoiorg/0436/ojs0660 Improved Estimatio of Rare Sesitive ttribute i a Stratified Samplig Usig

More information

Joe Holbrook Memorial Math Competition

Joe Holbrook Memorial Math Competition Joe Holbrook Memorial Math Competitio 8th Grade Solutios October 5, 07. Sice additio ad subtractio come before divisio ad mutiplicatio, 5 5 ( 5 ( 5. Now, sice operatios are performed right to left, ( 5

More information

XT - MATHS Grade 12. Date: 2010/06/29. Subject: Series and Sequences 1: Arithmetic Total Marks: 84 = 2 = 2 1. FALSE 10.

XT - MATHS Grade 12. Date: 2010/06/29. Subject: Series and Sequences 1: Arithmetic Total Marks: 84 = 2 = 2 1. FALSE 10. ubject: eries ad equeces 1: Arithmetic otal Mars: 8 X - MAH Grade 1 Date: 010/0/ 1. FALE 10 Explaatio: his series is arithmetic as d 1 ad d 15 1 he sum of a arithmetic series is give by [ a ( ] a represets

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

Chapter 7: Numerical Series

Chapter 7: Numerical Series Chapter 7: Numerical Series Chapter 7 Overview: Sequeces ad Numerical Series I most texts, the topic of sequeces ad series appears, at first, to be a side topic. There are almost o derivatives or itegrals

More information

Sequences, Series, and All That

Sequences, Series, and All That Chapter Te Sequeces, Series, ad All That. Itroductio Suppose we wat to compute a approximatio of the umber e by usig the Taylor polyomial p for f ( x) = e x at a =. This polyomial is easily see to be 3

More information

DEGENERACY AND ALL THAT

DEGENERACY AND ALL THAT DEGENERACY AND ALL THAT Te Nature of Termodyamics, Statistical Mecaics ad Classical Mecaics Termodyamics Te study of te equilibrium bulk properties of matter witi te cotext of four laws or facts of experiece

More information

Signals & Systems Chapter3

Signals & Systems Chapter3 Sigals & Systems Chapter3 1.2 Discrete-Time (D-T) Sigals Electroic systems do most of the processig of a sigal usig a computer. A computer ca t directly process a C-T sigal but istead eeds a stream of

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

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

September 2012 C1 Note. C1 Notes (Edexcel) Copyright - For AS, A2 notes and IGCSE / GCSE worksheets 1

September 2012 C1 Note. C1 Notes (Edexcel) Copyright   - For AS, A2 notes and IGCSE / GCSE worksheets 1 September 0 s (Edecel) Copyright www.pgmaths.co.uk - For AS, A otes ad IGCSE / GCSE worksheets September 0 Copyright www.pgmaths.co.uk - For AS, A otes ad IGCSE / GCSE worksheets September 0 Copyright

More information

Carleton College, Winter 2017 Math 121, Practice Final Prof. Jones. Note: the exam will have a section of true-false questions, like the one below.

Carleton College, Winter 2017 Math 121, Practice Final Prof. Jones. Note: the exam will have a section of true-false questions, like the one below. Carleto College, Witer 207 Math 2, Practice Fial Prof. Joes Note: the exam will have a sectio of true-false questios, like the oe below.. True or False. Briefly explai your aswer. A icorrectly justified

More information

Nonparametric regression: minimax upper and lower bounds

Nonparametric regression: minimax upper and lower bounds Capter 4 Noparametric regressio: miimax upper ad lower bouds 4. Itroductio We cosider oe of te two te most classical o-parametric problems i tis example: estimatig a regressio fuctio o a subset of te real

More information

Proof of Goldbach s Conjecture. Reza Javaherdashti

Proof of Goldbach s Conjecture. Reza Javaherdashti Proof of Goldbach s Cojecture Reza Javaherdashti farzijavaherdashti@gmail.com Abstract After certai subsets of Natural umbers called Rage ad Row are defied, we assume (1) there is a fuctio that ca produce

More information