exam review i - york universityjackie/teaching/lectures/2018... · 2019. 8. 30. · tnt (sundtat et...
TRANSCRIPT
Monday Dec.
10
Exam Review I
Glorification ,
a 4
→ Tci > = I
ntl
-
-
z.IT#stlunHITcn=y2.TxnIQIIiz.G.TT#tI)tl,,0cz7--Gzo(zoLz.5kn-DtOD⑦I= . .
. n - t=p - ?XG - Dtheists
,
-t2①GtD
i assume n -
- E " °
EE:* .
" - by "Tc⇒÷2 . T t④+ I
" "
→. - - - T .
. -
Given a recursive method .
void m C → {if C . . ) { -3 ;
else if C . - ) { -3 ;
gelse { me - > -
s
Prove by Math Induction :
D Prove base cases
I. H .
② State
Inductivenesson problem site N
⑦ Argueabout the correctness of problem size htt )
↳ apply the I H .
to conclude the proof.
at sum Cates as { a →
,
return sun A C as 0.
a. length- Ds
TntSundtC at ET Is
.
Tntfee ,TntE) {
-
if C from > to > { return 0,3
else if C from =-
- to stream a*L action ] ; }else { rattan] t Sumit Ca .
tone Is
to ) -
s 3} return
Tnt
Sundt( at ET Is
.
Tntfee ,TntE) {
Iif C from > to > { return 0,3
2 else if C from =-
- to Stream a*L at fun ] ; }
③else
sina.LIt
sumHE-
s 3} return
Food.
c Principle t.at ton to
" ↳
Baseline.
for empty array , we knewI s
theft1%9
.
Rekse.
State the followingInductive Hypothesis :
⑦To
" g:⇒as 'to si# rear .
, we do : afford t¥q*fTi ] subproblem .
D -
-
Iit .
↳ this to done at Line 3 with
i. .
.. . . .
. .
Zs 53 -
Fba Coy → e. a
.
THE ] fibbing C Tnt n > { ASA a ) →he
nee intents f. BAGS →TIES's?
.ge/IYod-results f. sacs , → TEy
return result ,
Feb Ist reggaefills Inks
need fib ArrayHenin
.YEH-
result -LfomJ= result I fan - Dt resultTfom -2 ] 's 2nd recursive
ABAYA ( n, fend , result ) ;
call fills "
} this value
H assumption: A > O
,b > O * I
at at a,
⇒ es , g
gcdcxsys-iffff-Iagreturnaa.to
?
g.
else Ires3b -
s
else I 2
→ if Cas b) I returngedsb)s3
→ else { return