Recurrences
Tin) +n -21-1%1
1k¥ [¥¥É ::::
John Rachlin
Copyright By PowCoder代写 加微信 powcoder
CS 5002 : Discrete
Northeastern
ReeurrenceRelat.co#
(and how to solve them)
techniques
converting
Sometimes it is easier to express a
a s a neccerrencerelat.CI :
a fo r formula
a n expressed
m ore prior terms
as a function of one or
reunrsivedefinition is the recurrence
plus initiaonditcons
A rith m e tic:
RecursiveDefa: An = an- ,
Quadraticsequences-i.ly
, 10 , 15,- . –
closed form
” Triangular num bers
RecursiveDefn: Tn=Tn- +n ;T,= 1
: 3 , 5 , 9 , 17 , 33 , 65 , . .
form : Recursive Defn
an = an=2am,
Using inductive hypothesis ?
Formal Proof By
induction :
verify this ? ‘y
Base case :
A , -2 -11=3 Inductive Case :
– 1 = ) – I Assume: ,r=2k-11 t
-* soverification-maybea=sy?isu
2/2^-1+1 a
y.gyn.y.g#
1 recurrence
want to be able to define the
form formula .
I,2,3,5, -.
8,13, (we’ll revisit this )
Recurrence : Fn = Fn- t Fn- z ; F.= 1 Fz=
Here the recursive definition
e a s ie r to
m odifications to the definition
us a,azAsayasa
n e w sequences :
Recurrence
Fn=Fn-,1-Fn-z O l I 2 3 5 8 13
2 2 4 6 10 16 26 42
Fn=2Fn, 1- Fn-2 0 I 2 5 12 29 to 169
Fn=Fn-,-12%-2 o l l 3 5 11 21 43
wM°trested in deriving d☐sedG formulas from the recursive definition .
why? Some algorithms are
by nature , so we can use these
techniques to analyze the asymptotic
complexity
algorithm .
soluing-ia-T-ationan-an.in
Sequence: ‘
5 , 7 , YYY Y
O “”4-15 , , 1
so this is clearly a From the definition : an
sequence . , = n
a-a’ =3 a3″=4
Let’s solve it a different way , this
iteration a n d substitution
=an-, +n ;a☐
A = Go + 1 ,
= (ao+1)+2
, =((ao+1)1-2)+ 3
= 4ao-11)-14 + 3) +4
an= ((– -. (ao+ 1)+2)+3)+- – – – J+n
Ék = 41- K=1
a) Repeatedly substitute
b) Look for a n emerging pattern
c) Derive a formula from the pattern .
an=3an +2 , ao, = I -,
5X17X53 x161
= 3139 -1 2) +2 = 329*-12.3 + 2
a } = Jaz -12 = 3/329,0-12-3 -12 ) -12
= 33A + 2-3″ t 2-3 1- 2 ☐
. – +3^-1)
-12.3^-2-1
3″ + 2. (11-3+32-1 .
S=I1-3-1 32-1.. . +3^-1
35 = 3 + 32-1
s-35=1 – 3
an=3″-3^-l-2.3”-
The recursive definition is something like this:
Tln ) = Running time to merge sort n numbers.
-14h -12 +1-(1^127) –
operations
e.g n= 17:
But for asymptotic analysis we can ignore
floor /ceiling functions , constants , lower
1-(n) ={2 1-(Vz) + n if n > 1
1-In) = n t 221-In/z)
411-1^14 )
1-In) = In
2 n 41^14 -121-1^18 ) )
1-(n)= 3h + 81-(9/8)
T.cn)= : 2k -1142k) kn +
To eliminate the recursive term , we note that the
algorithm bottoms o u t when 1 – (1) = I
1- (Msk) = 1
Ten)= kn +
= nlogzn+ n. I = Olnlogn)
2kt (n /2k)
= logan. n + 2105- n T
lone element )
1- In ) = -11^12 ) + C
=/(1-1^18) + c) + c) + c
= Tfryzk) + K- C
1-(n)=1-(1)+logan. C = clogan+ I
characteristicR.co# ( optional
Given an+ ✗an +pan-2=0 -,
If r, and rz are dist roots of
characteristic
polynomial
Or if only one
root : an=ar^+bn-
where a and b are determined from
initial conditions .
Example: An= 7-an- , -10 an- ~ ; 90=2,9,=3
μn: 0 I 2 3 4 5 6
.. characteristic
✗ (X – (11-5)–0
I -23 -171 -967 An-7-an-,1-loan-2 =0
2-7×-110–0
Solve fo r
So ✗= 2 or ✗=5
i. an=a2^_bÉ”@ at b = 2 ⇒za-126–4
an -1,2^-1,5
⇐ a=¥;b= – y,
ÉF i b o n a c c i
Fn- Fn – Fn -,z
✗= -b-tz.bz#-4a a = 1 , b= -1 , c=- I
“phi” ” psi”
with a-15=0 a 4 + BY
” The golden ratio ” = 1. 6180339887
g- = atb 1 ¥ .
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com