Recursion 5 Print

© All Rights Reserved

8 views

Recursion 5 Print

© All Rights Reserved

- WeldPlanner-2010_UsersGuide
- AOA exp2
- Implementing the Cut-And-Paste Operation in a Structured Editing Systems
- Linear-Time Algorithms for Encoding Trees as Sequences of Node Labels
- 5. Randomized Algorithms for Optimizing Large Join Queries - Ioannidis
- 01 Intro and Counting
- test2-soln
- 05-22Mergesort-2x2
- Syllabus of AP (v3.0)
- Master.pdf
- Chap A
- ds
- Download (5)
- Introduction to Search
- adaNotes-1
- acelerometro
- 10 Trees
- MCA 312 Design&Analysis of Algorithm QuestionBank
- Intergraph Placement Paper Whole Testpaper 28752
- Recursion Handout

You are on page 1of 7

Adamchik 1

Recurrences

Victor Adamchik

Fall of 2005

Plan

1. More on multiple roots

2. Inhomogeneous equations

3. Divide-and-conquer recurrences

Multiple roots

In the previous lecture we have showed that if the characteristic equation has a multiple

root then both

n n

an and an n

are solutions. Today we will prove this directly. Consider the second order recurrence

equation

an an 1 an 2

2

0

2 4 2 4

1 , 2

2 2

2

if and only if 4 . It follows 2 . To prove that

n

an n

n n 1 n 2

n n 1 n 2

Divide this by n 2

2

n n 1 n 2 0

V. Adamchik 21-127: Concepts of Mathematics

2

n 2 0

The first term is zero because is the roots of the characteristic equation. The second term

2

is zero because 4

and 2

.

n n

, n , n2 n

, ..., n p 1 n

an 3 an 1 3 an 2 an 3

an c1 c2 n c3 n2

an 5 an 1 7 an 2 3 an 3 0

a0 1, a1 2, a2 3

Inhomogeneous Equations

As an example of such recurrences we consider Fibonacci trees. This data structure is

defined recursively as follows:

the empty tree is a Fibonacci tree of order 0

a single node tree is a Fibonacci tree of order 1.

a Fibonacci tree of order n has a left Fibonacci subtree of order n 1, and a right

Fibonacci subtree of order n 2.

V. Adamchik 3

We want to count the number of nodes in a Fibonacci tree of order n. Let Tn denote the

number of nodes in a tree of order n. Then

Tn Tn 1 Tn 2 1

T0 0, T1 1

an 1 an 1 ... k an k f n

where all k are constants and f n is a function other than the zero is called an inhomoge-

neous linear recurrence equation with constant coefficients. There is no a known general

method for solving such equations. We consider a one important particular case when the

function f n is

n

f n pn

neous equation into a homogeneous one. Let us trace the idea on the Fibonacci tree recur-

rence. In order to cancel the right hand side, we consider the original equation along with

the one obtained by replacing n n 1

Tn Tn 1 Tn 2 1

Tn 1 Tn 2 Tn 3 1

Tn 2 Tn 1 Tn 3 0

T0 0, T1 1, T2 2

V. Adamchik 21-127: Concepts of Mathematics

This is the forth order homogeneous equation, which we can solve by the characteristic

equation

Solve x ^ 3 2 x^2 1 0, x

1 1

x 1 , x 1 5 , x 1 5

2 2

n n

1 5 1 5

Tn c1 c2 c3

2 2

T0 c1 c2 c3 0

1 5 1 5

T1 c1 c2 2

c3 2

1

2 2

1 5 1 5

T2 c1 c2 2

c3 2

2

has a solution

5 3 5 5 3 5

c1 1, c2 , c3

10 10

After some algebra, we get

n n

1 1 5 1 1 5

Tn 1

5 2 5 2

n 1 n 1

1 1 5 1 1 5

5 2 5 2

Tn Fn 1 Fn 1

or

Tn Fn 2 1

wherer Fn is the Fibonacci number. You will see this sequence again in 15-211 when

study AVL trees.

V. Adamchik 5

Divide-and-conquer Recurrences

The divide-and-conquer algorithm consist of three steps:

dividing a problem into smaller subproblems

solving (recursively) each subproblem

then combining solutions

Suppose Tn is the number of steps in the worst case needed to solve the problem of size n.

Let us split a problem into a 1 subproblems, each of which is of the input size bn where

b 1. Observe, that the number of subproblems a is not necessarily equal to b. The total

number of steps Tn is obtained by all steps needed to solve smaller subproblems Tn b plus

the number needed to combine solutions into a final one. The following equation is called

divide-and-conquer recurrence relation

Tn a Tn b f n

Tn 2 Tn 2 n

Tn 3 Tn 4 n2

Tn Tn 3 n log n

the iteration method

the tree method

the master-theorem method

MergeSort

Mergesort involves the following steps:

Divide the array into two subarrays

Sort each subarray

Merge them into one (in a smart way!)

Example.

27 10 12 25 34 16 15 31

27 10 12 25 34 16 15 31

V. Adamchik 21-127: Concepts of Mathematics

10 12 25 27 15 16 31 34

3. merge into one (comparing, one by one, the paired elements from the two parts)

(10 15) (12 15) (25 15) (25 16) (25 31) (31 27) (31 34)

10 12 15 16 25 27 31 34

Let Tn denote the running time of the algorithm, i.e. the number of comparisons needed to

sort n elements. We have the following recurrence equation for Tn :

Tn 2 T n2 n 1

T1 0

To get the feeling for the nature of the solution we consider a case when n is a power of 2,

namely n 2k . Then

T2k 2 T2k 1 2k 1

T2k T2k 1 1

1

2k 2k 1 2k

T2k 1 T2k 2 1

1

2k 1 2k 2 2k 1

T2 T1 1

1

2 20 2

Using a backward substitution, this leads to

T2k 1 1 1

1 1 ... 1

2k 2k 2k 1 2

T2k 1 1 1

k ...

2k 2k 2k 1 2

The finite sum is the geometric series

k

xk 1 1

xj

j 0

x 1

Therefore,

V. Adamchik 7

k k 1 k 1

1 1 2

1 1

1 1 1

1

j 1

2j j 0

2j 1 2k

2

Thus

T2k 1

k 1

2k 2k

or

T2k k 1 2k 1

Tn n log n n 1

- WeldPlanner-2010_UsersGuideUploaded by'Magda Looney Tesalonika'
- AOA exp2Uploaded bySakharam Gawade
- Implementing the Cut-And-Paste Operation in a Structured Editing SystemsUploaded byvthung
- Linear-Time Algorithms for Encoding Trees as Sequences of Node LabelsUploaded byravg10
- 5. Randomized Algorithms for Optimizing Large Join Queries - IoannidisUploaded byPanos Koukios
- 01 Intro and CountingUploaded byNam Nguyễn Văn
- test2-solnUploaded by2376271
- 05-22Mergesort-2x2Uploaded byDellendo Farquharson
- Syllabus of AP (v3.0)Uploaded byTanat Tonguthaisri
- Master.pdfUploaded byNishu Rave
- Chap AUploaded byabirh
- dsUploaded byVishal Rajput
- Download (5)Uploaded byKaren Savage
- Introduction to SearchUploaded byלורנסמבאאבו
- adaNotes-1Uploaded bypankajghorela
- acelerometroUploaded byDiego Ricardo Paez Ardila
- 10 TreesUploaded byDũng Gooner
- MCA 312 Design&Analysis of Algorithm QuestionBankUploaded bynbpr
- Intergraph Placement Paper Whole Testpaper 28752Uploaded byHemanth Vidyamari
- Recursion HandoutUploaded byManideep Paduchuri
- CS145Uploaded byNivedita Mittal
- Multinomial Logistic Regression Model.txtUploaded byHitesh Takhtani
- ELFINI_Structural_Analysis_CATIA.pdfUploaded bySergey Fedorinov
- bstreeUploaded byraj khanna
- PramodUploaded byKrishan Kant Shukla
- CS502 Quiz No.1 30-04-2012Uploaded bySohail Ahmad
- Ch-3Uploaded bymenber
- Huffman CodingUploaded byचन्द्र विलाश भूर्तेल
- OPmatlabUploaded byDessy Wulandari
- Avl TreesUploaded byjesusmp97

- Ainsworth Dental Gypsums Plaster EtcmsdsUploaded byAnonymous gUySMcpSq
- Parramatta Light RailUploaded byAnonymous gUySMcpSq
- What is NoSQL Nonrelational Databases, Flexible Schema Data ModelsUploaded byAnonymous gUySMcpSq
- Dolinsky Prezentacia Stat ModelingUploaded byAnonymous gUySMcpSq
- SPE_ RMD_v1_Refractory Model Dip.pdfUploaded byAnonymous gUySMcpSq
- Growing By Adapting At Speed.pdfUploaded byAnonymous gUySMcpSq
- ThesisUploaded byAnonymous gUySMcpSq
- Printer Error! Intellectual Property and Recycled Printer Cartridges, Part 2 - Knowledge - Clayton UtzUploaded byAnonymous gUySMcpSq
- Smartening Up With Artificial IntelligenceUploaded byAnonymous gUySMcpSq
- What Next for BlockchainUploaded byAnonymous gUySMcpSq
- SAS STAT 14.3 WhatsnewUploaded byAnonymous gUySMcpSq
- 60b9ba_2f10ea89a96141f8b30a1b11d3d581c0Uploaded byAnonymous gUySMcpSq
- Home Reno Ideas - Layout Improvements - HomeUploaded byPETER
- Travel Content Takes Off on Youtube ArticlesUploaded byAnonymous gUySMcpSq
- Enterprise Analytics in the CloudUploaded byAnonymous gUySMcpSq
- One WorldUploaded byAnonymous gUySMcpSq
- Cisco's John Chambers on the Digital EraUploaded byAnonymous gUySMcpSq
- Microsoft’s Asean ExperienceUploaded byAnonymous gUySMcpSq
- Met01306f MsdsUploaded byAnonymous gUySMcpSq
- Usg Regular Dental PlasterUploaded byAnonymous gUySMcpSq
- Die Stone Conditioner 7.12!1!3Uploaded byAnonymous gUySMcpSq
- Msds SdhUploaded byPETER
- Perfectim Msds Die Hard Thin l 149 0113Uploaded byAnonymous gUySMcpSq
- Thinner For Surface Hardener.pdfUploaded byAnonymous gUySMcpSq
- Vertex Self Curing PowderUploaded byAnonymous gUySMcpSq
- 989-800-22Uploaded byAnonymous gUySMcpSq
- Comp SiteUploaded byAnonymous gUySMcpSq
- Thinner For Surface Hardener.pdfUploaded byAnonymous gUySMcpSq
- SdsUploaded byAnonymous gUySMcpSq
- Methacrylate Esters Safe Handling Manual (2008Uploaded byAnonymous gUySMcpSq

- H.K. Moffatt- Vortices subjected to non-axisymmetric strain - unsteady asymptotic evolutionUploaded byVortices3443
- S Kuliah16Uploaded byHafiz Mahaad
- Cheat SheetUploaded byMario Gini
- Tratado integrais 2Uploaded byPatricia Sousa
- Ma 1201Uploaded byAnu Parthee
- Postulates of Quantum MechanicsUploaded byBenjaminLloyd
- Mat Lab for Sci Lab UsersUploaded byDeepank Ch
- 49-Thesis-proposal.pdfUploaded bymaxamaxa
- Basic Simulation Lab FileUploaded byAnonymous zpLxw2fw
- 5factoring-polynomials.pptUploaded bySowon Kim
- The Geometry and Thermodynamics of Dissipative Quantum SystemsUploaded byemiranuar
- 1048 (1)Uploaded byfredyalz
- Optimization with QuantLibUploaded byMauricio Bedoya
- Eee230 Engineering Optimization Using Soft Computing Th 1.00 Ac21Uploaded bySharvanMvs
- Exact Spherical Wave Solutions to Maxwells Equations With ApplicaUploaded byBrandon Stephens
- Math 251 Summer 2011 FinalUploaded byleetony91
- 1.3 Epicycloid ConstructionUploaded byMartin De Boras Pragash
- 1112012913Dynamics Response Spectrum Analysis.pdfUploaded byHectoreRodriguezl
- Choose the Right ModulusUploaded byheiricar
- Cornus SpiralUploaded byzjnsrbt
- reflection in a lineUploaded byapi-291428736
- alg1m1l4-binomial theorem 2Uploaded byapi-276774049
- Maxima MinimaUploaded bySridhar Dv
- 2005AMC10BUploaded bygzautan
- Network AnalysisUploaded bysailorweb
- runge-kuttaUploaded byTaimoor Afzal Kiani
- Canonical FormsUploaded byBrahadeesh Perinkolam Murali
- Lesson 01 Anti DifferentiationUploaded byAgnes Alexsandria Lalog
- 5.8-Rational Zero Theorem - StudentsUploaded byEnas Basheer
- Angelaki_Duffy_SchizoMathUploaded byvbbaumhoff

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.