8 views

Uploaded by Anonymous gUySMcpSq

Recursion 5 Print

- 6e-ch7
- fibotrees
- Pointer.f90
- comp250-hw4
- Data Structures
- Large-Scale Wire-Speed Packet Classification on FPGAs.pdf
- Recurrence
- Forms Symfony2
- lab programs algorithms
- DSP
- lecture3.pdf
- Software Developer Interview Questions
- Binary Search Tree
- BTech EC Syllabus
- 19_3_RTU560_Exercise_3_Communication_IEC_E.pdf
- 3DModeling in GIS
- algo (Autosaved)
- Recursion
- Squinting at Power Series
- documentation

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

- 6e-ch7Uploaded byanasuriraju
- fibotreesUploaded byjbond07
- Pointer.f90Uploaded byvaskomane
- comp250-hw4Uploaded byRynoxo
- Data StructuresUploaded byNehalMishra
- Large-Scale Wire-Speed Packet Classification on FPGAs.pdfUploaded byAnonymous kddQfsna
- RecurrenceUploaded byjohn17321
- Forms Symfony2Uploaded bycquinto
- lab programs algorithmsUploaded byRavi Teja
- DSPUploaded bysum1oru
- lecture3.pdfUploaded byblackhatson13
- Software Developer Interview QuestionsUploaded byAhmet Yerli
- Binary Search TreeUploaded byanand
- BTech EC SyllabusUploaded bySachin Dhinwa
- 19_3_RTU560_Exercise_3_Communication_IEC_E.pdfUploaded byngocanhvy
- 3DModeling in GISUploaded bySaif Aryan
- algo (Autosaved)Uploaded byMohit Kumar
- RecursionUploaded bygbland
- Squinting at Power SeriesUploaded by.xml
- documentationUploaded bysk_firdous
- NewUploaded byemalis
- java programming II Final Exam Study SheetsUploaded bytomritch
- CPUploaded byAlyssa Marie Sagaoinit
- v3ch03Uploaded byАлексей Якушин
- 112102-112105Uploaded byDevraj Tomar
- Analyzing RecursionUploaded byMugur Anghel
- TreesUploaded byPrateek Dhawan
- Binary Search TreeUploaded bySandeep Sahu
- xDUploaded byMinxuan Chan
- Interview Study Guide - CS FundamentalsUploaded bymonika

- SAS STAT 14.3 WhatsnewUploaded byAnonymous gUySMcpSq
- Travel Content Takes Off on Youtube ArticlesUploaded byAnonymous gUySMcpSq
- One WorldUploaded byAnonymous gUySMcpSq
- 60b9ba_2f10ea89a96141f8b30a1b11d3d581c0Uploaded byAnonymous gUySMcpSq
- Microsoft’s Asean ExperienceUploaded byAnonymous gUySMcpSq
- Enterprise Analytics in the CloudUploaded byAnonymous gUySMcpSq
- Lấy Chồng Việt Kiều Mỹ 10 Năm Chưa Làm Đám Cưới Vẫn Hạnh Phúc Không Ai BằngUploaded byPi
- What Next for BlockchainUploaded byAnonymous gUySMcpSq
- Parramatta Light RailUploaded byAnonymous gUySMcpSq
- ThesisUploaded byAnonymous gUySMcpSq
- Printer Error! Intellectual Property and Recycled Printer Cartridges, Part 2 - Knowledge - Clayton UtzUploaded byAnonymous gUySMcpSq
- What is NoSQL Nonrelational Databases, Flexible Schema Data ModelsUploaded byAnonymous gUySMcpSq
- Home Reno Ideas - Layout Improvements - HomeUploaded byPETER
- Cisco's John Chambers on the Digital EraUploaded byAnonymous gUySMcpSq
- Dolinsky Prezentacia Stat ModelingUploaded byAnonymous gUySMcpSq
- Compsite.pdfUploaded byAnonymous gUySMcpSq
- Perfectim Msds Die Hard Thin l 149 0113Uploaded byAnonymous gUySMcpSq
- Smartening Up With Artificial IntelligenceUploaded byAnonymous gUySMcpSq
- Growing By Adapting At Speed.pdfUploaded byAnonymous gUySMcpSq
- Met01306f MsdsUploaded byAnonymous gUySMcpSq
- Comp SiteUploaded byAnonymous gUySMcpSq
- Thinner For Surface Hardener.pdfUploaded byAnonymous gUySMcpSq
- 989-800-22Uploaded byAnonymous gUySMcpSq
- SPE_ RMD_v1_Refractory Model Dip.pdfUploaded byAnonymous gUySMcpSq
- Msds SdhUploaded byPETER
- Vertex Self Curing PowderUploaded byAnonymous gUySMcpSq
- Die Stone Conditioner 7.12!1!3Uploaded byAnonymous gUySMcpSq
- Vertex Rapid Simplified LiquidUploaded byAnonymous gUySMcpSq
- Usg Regular Dental PlasterUploaded byAnonymous gUySMcpSq
- Ainsworth Dental Gypsums Plaster EtcmsdsUploaded byAnonymous gUySMcpSq

- nicUploaded byBala Ji
- Bin Packing AlgorithmsUploaded byKha Man
- bbischUploaded byjayanthbumaiyya
- Java Programming Assignment HelpUploaded byAugustine Barlow
- SortingUploaded byShafaq Khan
- Chapter 11 - Analysis of Algorithms(4)Uploaded bysandip
- C Programming and Data Structure_notesUploaded bySupragy Bhatnagar
- 2nd Year SyllabusUploaded bySayan Gupta
- Master of Science-Computer Science-SyllabusUploaded byManish Mittal
- Assignment 02Uploaded byShariq Masood
- EC6301_qb.pdfUploaded byVive Kowsal Yaniss
- An Efﬁcient Python Module for Lexical Distributional SimilarityUploaded byEdmar Oliveira Ferreira
- Front End HandbookUploaded bymanikantamnk11
- 11100827Uploaded byChandra Bhushan Sah
- C and Data StructureUploaded byUnmesh Mandal
- lects1-3Uploaded byhungbkpro90
- LCRCalicoV2Uploaded byWayne Chien
- 326Uploaded byaltamashshaikh09148
- blow upUploaded bynavneetgupta13
- Data Structures WikibooksUploaded byAnkit
- LAB BOOK (Seismic Imaging and Modelling) Paul Ssali 17390138 Submitted.pdfUploaded byJill Dagreat
- Lecture Notes COMP3506Uploaded byJack
- DataStage 7Uploaded bySai Vishnu Vardhan
- Computer Science & EngineeringUploaded byPHI Learning Pvt. Ltd.
- Algorithms should I know.pdfUploaded byraushanunique
- Topo SortUploaded bysankar_mca227390
- Designing High Performance BIRT ReportsUploaded byPiaPedrini
- cd_qb.xlsxUploaded byAjax22
- Big o Cheat SheetUploaded byXinyu Hu
- 1 Year Lab Python 2017 ManualUploaded byAnonymous pHX5EaA