CPS 151
Study Guide for Test #3 on November 7, 2013
The quiz will cover material in Chapter 14 (14.1-14.6, 14.8), Chapter 16 (16.1 16.3) an
Chapter 1! (1!.1, 1!."). #ere i$ a $election o% what coul &e on the te$t'
(hat i$ a recur$ive %unction)
o *unction that call$ upon it$el% irectl+, or inirectl+
#ow oe$ the recur$ion $top)
o The recur$ion $top$ when the &a$e ca$e parameter i$ met
(hat i$ a &a$e ca$e)
o The ,arameter to let the %unction -now when to en
(hen mi.ht a recur$ive %unction e/ecute in%initel+)
o The &a$e ca$e i$ not e%ine, or the parameter i$ impo$$i&le to meet
0irect v$. inirect recur$ion
o 0irect' *unction irectl+ callin. it$el% (count own)
o 1nirect' *unction callin. another %unction that call$ it$el%
2e a&le to write recur$ive %unction$ $imilar in i%%icult+ to the in cla$$ a$$i.nment or the
character $earch or %actorial recur$ive %unction$ we went over in cla$$
3now how a recur$ive &inar+ $earch %unction wor-$
o 4et m to mile o% $orte arra+
o 1% a5m6 77 /, return m
o 1% a5m6 8 /, recur$ivel+ $earch a5lo9m-16
o 1% a5m6 : /, recur$ivel+ $earch a5m;19hi6
3now how <uic-$ort wor-$
o 0etermine$ a value a$ a pivot value
o 4hi%t value$ $o that le%t o% pivot are all le$$ than
o 4hi%t value$ $o that ri.ht o% pivot are all .rater than
o 2a$e ca$e i$ when a $ie ha$ a $ize :7 1
(hat i$ a pivot element) (hat oe$ the partition %unction o)
o = pivot value i$ a value in the correct po$ition, $o that all value$ to the le%t an
ri.ht are all le$$ than an .reater than the value
o the pivot element i$ ta-en to &e the element at the $tart o% the $u&ran.e to &e
partitione.
1nt pivot>alue 7 arr 5$tart6?
1nt pivot,o$ition 7 $tart?
o @@ Aearran.e the re$t o% the arra+ element$ to partition the $u&ran.e %rom $tart to
en
(hat i$ an e/ception in C;;)
o =n une/pecte event or conition that occur$ while the pro.ram i$ runnin. an
ma-e$ it impo$$i&le to continue
(hat i$ a tr+ &loc-) (hat i$ a throw point) (hat oe$ the catch &loc- o)
o Tr+ B C call$ the coe neee to throw an e/ception
o Throw / (Throw$ $omethin. to $i.nal the error (cout :: DErAFA GE44=HE
IFF2J))
o Catch BC u$e to hanle e/ception$
#ow are multiple e/ception$ hanle)
o Gultiple &loc-$ can &e attache to the $ame &loc- o% coe. The catch &loc-$
$houl hanle e/ception$ o% i%%erent t+pe$
3now what a %unction template i$ (itK$ purpo$e) an how to e%ine an u$e
template :cla$$ T8
T $quare (T num&er)
Breturn num&er L num&erC
o *unction template- ,attern %or creatin. %unction e%inition$ that i%%er in t+pe
(hat i$ a cla$$ template an how oe$ it i%%er %rom a %unction template)
o = template u$e to e%ine cla$$e$
o Mnli-e a %unction, a cla$$ template i$ in$tatiate &+ $uppl+in. the t+pe name (int
%loat, $trin. etc.) at o&Nect e%inition
3now what a lin-e li$t i$ an how each noe i$ $tructure
o = $equence o% ata noe$ that each point to the ne/t one
o Oa$t noe ha$ a pointer to IMOO
3now how to &uil a lin-e li$t %rom $cratch, how to traver$e a lin-e li$t, an how to
appen a new noe to the en o% a lin- li$t
4truct Oi$tIoe
B
Oi$tIoe Lne/t?
1nt value
C?
Oi$tIoe Lne/t?
1nt main()
B
Oi$tIoe Lhea?
@@ IF (=P 1 (FIT OET 1T HET 1I T#E (=P O13E O=4T T1GE =I0 1* 1T
0FE4I T#=T T#EI GE44=HE T#E FMTEA 4#EOO 2EC=M4E =I0 1T4 IFT
,F4412OE 2CMQ 31II13M P=P P=P =I0 G=P2E GFAE FA OE4
#F( 0FE4 T#E *1I=O EI0 2EH1IE T#E IERT (=>E F* *1I=O
HE4T4MH= TEI4#FM 2CMQ F* =>=1O=2OE TA1=O4 =I0 ,=AT1T1FI4 T#EAE 14
IF (=P 2CMQ =I1GE 14 =G=Q1IH =I0 T#EAE 14 IF (=P TF CFMITEA=CT
Ooo- at quiz S3 an concentrate on an+ material that +ou ha pro&lem$ with. Ooo- over +our
note$, rea in the &oo- an wor- throu.h the e/ample$ in the &oo- an tho$e we i in cla$$.
*or recur$ion e$peciall+ wor- throu.h $olvin. pro&lem$ ... practice practice practiceT =n a$
alwa+$, come &+ an tal- to me i% +ou are unclear a&out an+ concept.