CS61A_sp92_f

CS61A_sp92_f - CSAF ina l|M ay, Y ou rnam e log inca{ D...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSAF ina l|M ay, Y ou rnam e log inca{ D iscu ss ionsect ionnum ber TA 'snam e Th isexam isw orthpo in ts ,or.%o fyou rto ta lcou rsegrade .Theexam con ta in s s ixquest ion s . Th isbook letcon ta in se levennum beredpages(bo ths ideso fs ixsheets)inc lud ingthecover page .Pu ta llan sw ersonthesepages ,p lease ;don 'thand instrayp ieceso fpaper .Th isis anopenbookexam . W henw r it ingp rocedu res ,don 'tpu tinerrorchecks .A ssum ethatyouw illbe g ivenargum en tso fthecorrecttype . O u rexpecta t ion istha tm anyo fyouw illno tcom p leteoneortw oo fthesequest ion s .If youndonequest ionespec ia llyd icu lt , leaveitforla ter ;startw iththeonesyound eas ier . = = = = = = to ta l = Q uest ion(po in ts) : Every in tegergrea terthanhasa un iquepr im efac tor iza tion .Tha tis ,thereisexact ly onew aytha teach in tegercanbeexp ressedasap roducto fp r im enum bers .F orexam p le , is . isju st. is . is .(N o t icetha tthesam ep r im ecanbe u sedm orethanonce ,asinthecaseo f.) Y ouareg iventhestream s integers (con ta in inga llthepos it ivein tegers)and primes (con ta in inga llthep r im enum bers) .(Y ouneedno trep roducethecom pu ta t ion sinthe booktha tgenera tethesestream s .) (a )W r itethefunct ion factors tha ttakesan in tegerasitsargum en tandretu rn sa list (no tastream )con ta in ing itsp r im efactor iza t ion .F orexam p le : >(factors) ( ) >(factors) () (b )C on structthestream factor-stream tha tcon ta in sthep r im efactor iza t ion so fa llthe pos it ivein tegers . Y ou rnam e log inca{ Q uest ion(po in ts) : W e 'rego ingtocrea teanab stractda tatypefort im eso fday(hou rsandm inu tes) .T o m aketh ingss im p ler ,w e 'llu se-hou rt im es ,inwh ichpm ishou r.Y ouarego ingto im p lem en tth isab stractda tatypeu s ingtw od ierentin terna lrep resen ta t ion s . Thecon structorfort im eso fday isca lled time .Ittakestw oargum en ts :thehou rsandthe m inu tes .So:amwou ldbe (time ) . W ea lsow an tthefo llow ingth reeopera torsfort im es : (hourt) retu rn sthehou rport iono ftheg ivent im e . (minutet) retu rn sthem inu teport iono ftheg ivent im e . (hour?t) retu rn s #t (true)ifthet im e t isanexacthou rt im e( like:) ;itretu rn s #f (fa lse)o therw ise . (a )Im p lem en t time , hour , minute ,and hour? u s ingan in terna lrep resen ta t ion inwh ich at im eisrep resen tedasalisto ftw onum bers .Tha tis ,:amshou ldberep resen ted in terna llyasthelist ( ) . Th isquest ioncon t inuesonthefo llow ingpage . Q uest ioncon...
View Full Document

Page1 / 11

CS61A_sp92_f - CSAF ina l|M ay, Y ou rnam e log inca{ D...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online