exam review i - york universityjackie/teaching/lectures/2018... · 2019. 8. 30. · tnt (sundtat et...

9
Monday Dec 10 Exam Review I

Upload: others

Post on 02-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

Monday Dec.

10

Exam Review I

Page 2: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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

Page 3: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

i assume n -

- E " °

EE:* .

" - by "Tc⇒÷2 . T t④+ I

" "

→. - - - T .

. -

Page 4: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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.

Page 5: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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

Page 6: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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

Page 7: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

i. .

.. . . .

. .

Page 8: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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

Page 9: Exam Review I - York Universityjackie/teaching/lectures/2018... · 2019. 8. 30. · Tnt (Sundtat ET s I fee Tnt, E) Tnt { if Cfrom > to > I {return 0,32 else if Cfrom =--to Stream

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

[email protected]%÷¥⇒