Advanced Recursion 2
Advanced Recursion 2
clapping
Hanoi No of towers 3
Towers of
A B C
I
I to e
Ry on Amovement
cannot be placed
1 Biggerdisk µ A C
smaller disk A B rare
towers
2 A B
a
of
top
disk at discs
only move f 1 C B 1,2 are
2
You can
c
3 a must
a time
1 B A
2 B C
A C
1
I I I
Movements 1 Anc
M2
A
It
Movement I A B
2 A C
1 B C
Ma
I p I
Movement I A B A to B
2A more s discs from
It tookus if stops to just
1 B C
z A B
I c A X
2 G B
1 A B
My
IÉ
I I
B c
1
g 2 BSA
q A C Y A c
e A
1
1 B L z B C
3 A B e A B
1 C A q A c
g C B C
1 B
1 A B
steps
Mdiscs dat
sie
toy É
I
TOHRecursion
Tracing
Toni I it I
toucanT
ac iÉ
is
tonic t D tomcib.tn 2
Bd
tonight p
any titty
Kii Toyo
a time p 1 ASC
1B A
i A B
2 AaB 2
TC J
t e B C Recursive Relations
A p
3 A C 3
B A
1 B A 1
B C Pratt 11017
2 B C 2
1 A
C 1 Asc
Bear
sam AED
1
I
É
1 69discs a 64
I disc as I day 264 1 days
3days
2discs 260 a 1018days
3discs as 8ndays
2 years
Y discs 15days
1days ftp
Ndisys
12
T 012M
I KthSymbol
o 01 and i lo
by
Rows are generated replacing
row find Kthindexsymbol
Givan N K At Nth
K O I 2 3 45 67 8 9 10 11 12 13 14 15
1 o I 2
s 2
2
3 1158 y 22
2
4 O 1 o o 1
1 I 0 1 o o 1 I 0 0 1 0 I 1 0 16 27
5 o
N k ans
6 O
y
I
5 13 will always be validvalues
Not possible A and K
2 3
8 i I
5
1 Bruteforceway
and get Kthindeed value
Generate
nth row
1 0 2N
204214214234 2M
T E
Contraints
W C Na 105
LI 105 2 elements
1 LIN willI have
natron
1 EK 4 1018
HIM
Which element is
generating
4throw Brdindex
5th now 7thindex
index
4th row 3rd t
5th show 6thindex
4th how 5thindex
5th now 11th index
observations
M 1 throw k index
row inth indeed
element generated by
D ath
ith a
previous
Moves Y I
I
gin
03
means armament
at even in child row Data is same as parent
3 If you
are
as parent
Data is reverse
are at odd in child rows
If you
Abode
h
int find N K
OCN X
TIM
intual find N 1,142
if 114
i 2 071 TIKI TLKK t I
117Kiseven 014214
I return val TC
Onelasttwist
Orel
hit thisodd K 2M I
In v c
I
I vali vat o I
return
valil 0 01422
T.cz oflyk
c of M or day Mr
T
1018
105 can k exceed
e.g N te
d hey
1018 I ralno.nl
of K
i
limited by value
TC is
X
e 14
105 K l
g
N 105 1,0
News 14 100
ej
105 1,50
lo 3 14
45 7,6
6 105
B 3 return
665 6,1
4105 7,0
Master's theorem
Simplified
power ofM
TN at Mlb y my
t dogba
c TCM O Nt
t
if o at logM
t c Tcm
if
tec TCM OfMY
if
TCM T N E H
271412 t I e 2
g
e IT A 1 3 2 Ce o
g 5 2 0 0 9
9 2 c
t hey l o
to log22 1
t C TC OHM
O M
TC
KTLA 7 I
eg 9 TCM
2T Mls N
N not
e 3
g T master's theorem does
a 2 6 2 C I work here
C
substitution method
to log 2 1 Solveusing
Mayne
T C O
satingM
Monday congest
31stJuly PS
session
LLIdas