UCF Computer Science Foundation Exam Study Plan
UCF Computer Science Foundation Exam Study Plan
byhttp://www.reddit.com/user/DaffUCF/
August17,2014
Therearenoshortcutsorsecretstodoingwellontheexam.Youneedtoknowyourstuff.This
guidecontainsmytips,linkstoresources,andflashcardsIusedtostudyfortheexam.
Ifyoufollowthroughwiththisguide,inadditiontowhatyoulearnedinyourclasses,youshould
knowyourstuff.Goodluck!
HowmuchtimeshouldIstudy?
Thisreallydependsonyouandhowwellyouunderstoodthematerialinyourclasses.Iveknown
somestudentswhodidntstudyatallandtheypassedthefirsttime.Othersneedtorelearn
entiretopics.Justbehonestwithyourselfabouthowwellyouknowthetopicsshownbelow.If
yourenotgoodwithmanyofthem,thengiveyourselfalotoftimetostudy.
Itsbesttostartearly.Itsaloteasiertostudyfor2hourseverydayforamonth(60hoursof
studyingbetterthanatypicalstudent!)thanitistostudyfor4hourseverydayfortwoweeks.It
willgiveyourbrainmoretimetodigesttheinformationanditwonttakeoveryourlife.
DontleaveituntilFinalsweekbeforeyoustartstudying.Youllbetoobusyandtiredwithyour
classes!
Studyinshortburstsof45minutes,thenstandupandtakeabreakfor1015minutestorest
yourmind.Goforashortwalk,doyourlaundry,eatsomefruit,orwhatever.Getawayfromthe
paperandlaptop.
Ifyourenearthebeginningofyoursemester,youcouldstudywellforonlyanhoureveryday.
Youwouldhave100+hoursofstudy(overkill!)andwillprobablydowonderful.Thatsalotof
practiceforjustoneexam.
Ifyouhaveprocrastinationproblems,dowhateverittakestogetridofthem.Internetbothering
you?Unplugyourmodem,orleavethehouseandstudyinthelibrary.Addictedtoyourmobile
Reddit?Giveyourfamily/friendyourphoneanddontletthemgiveitbackuntilyouredone.Itsa
loteasiertojustgetridofthedistractionthantotryusingyourwillpowertoovercomeit.
GeneralTips:
Neverleaveaquestionblank.Atleastwritedownwhatyourethinking.Evenifyoureonly
given1pointforit,itsbetterthannothing.Everypointcounts.
Foreachtopicshownbelow,firstreviewthelectures,thenreadtherelatedmaterialfrom
thetextbook,thendoatleastafewexercisesforpractice.Ifyouknowthetopicverywell,
youcanskipreadingthetextbook.
Asyoucompleteeachtopic,crossitoffthelist.Youllseehowyoureprogressingover
time.Reviewcompleteditemsperiodically,especiallyifyouwererustywiththem.
Specificquestionsarentusuallyrepeated.Forexample,iftheyaskedaRulesof
Inferencequestiononthelastexam,theyprobablywontaskitonthenextexam.Theres
noguarantee,buthistoricallyweseethisistrue.
However,certaintopicsarealwaysasked.Youreguaranteedrecursionquestions.Youre
guaranteedsomesortofbinarytreequestion.Youreguaranteedtohaveaproof.Youll
beaskedaboutprobabilities.Andsoon.
Somepeoplejustpracticethepreviousfoundationexams.Thatsnotbad,butmightnot
beenough.Forcertainproblems(suchasproofs)itwonthelpyouunlessyouhavea
goodunderstandingofit.Sotakethetimetoreadthelecturesand/ortextbookwhenyou
needto.Havingagoodunderstandingismoreimportantthanmemorizingahandfulof
problems.
Whendoingfoundationexampractice,trygivingyourselfonly10minutestocompletea
question.Thisistohelptrainyourbraintoworkquickly,becauseyouonlyhave3hours
toansweraround20questionsontheexam.
TryalternatingbetweenCSandDStopicseachday.E.g.ifyouwereplanningtostudy
for4weeks,dontdoallCSweeks12andthenDSforweeks34.Bytheendofweek4,
youmayhaveforgottensomeoftheCSstuff.Mixitup,keepbothtopicsfreshinyour
mind.YoucouldreaduponStacksforCS,andthenProofbyInductionforDS.
Quizlet.comisgreatforcreatingflashcards.Idrecommendcreatingflashcardstohelp
rememberBigOtimesforcommonalgorithms,alongwithanythingelseyoumayhave
troubleremembering(suchasformulasforcombinationsandpermutations).Alistof50+
flashcardsisprovidedattheendofthisdocument.Practicethemeverydayfor1015
minutesandyoullrememberthemeasily.
FindprogramsonlinetopracticeheapandAVLtreeandBinarySearchTree
inserts/deletes/etc.JustdoaGooglesearchforAVLtreeappletandthingslikethat.For
example:http://www.site.uottawa.ca/~stan/csi2514/applets/avl/BT.html
Youcanusethesetohelpcreatepracticeproblemsforyourself.Trycreatingtricky
insertionanddeletionsforAVLtreeswhichwouldrequiremultiplerotations.They
probablywontgiveyouasimpleoneontheexam.Knowhowtoidentifywhichnodesare
A,B,C(seeSarahslectures).
Practicewritingyourcodingsolutionsonpaper,justlikeyoullbedoingontherealexam.
Itfeelsverydifferentthantypingitonacomputer.
PracticeEVERYTHINGonpaper,actually.Simulatetherealexamascloselyas
possible.
Thenightbeforetheexamgetagoodamountofsleep.Haveahealthybreakfast.You
dontwanttofeeldrowsyorhaveaheadacheduringtheexamtrustme!
HelpfulLinks
http://www.cs.ucf.edu/academics/foundationexam.php
http://bigocheatsheet.com/
Probabilityhttp://www.math.uconn.edu/~wilkins/math3160s13/
https://openlibrary.org/books/OL1087438M/Data_structures_algorithms_and_software_pr
inciples_in_C
HelpfulComputerScienceLectures
Sarah:http://www.cs.ucf.edu/courses/cop3502/fall2011/Lectures/index.html
Jonathan:http://www.cs.ucf.edu/courses/cop3502/spr2011/notes/notes.html
(ThePDFlinkswork)
Personally,IneverunderstoodRecurrenceRelationsuntilIreadJonathansslidesonthetopic.
Arup:http://www.cs.ucf.edu/~dmarino/ucf/transparency/cop3502/
HelpfulDiscreteStructuresLectures
Arup:http://www.cs.ucf.edu/~dmarino/ucf/transparency/cot3100/
Also,thetextbookisverygoodatexplainingthissubject...Inmyhumbleopinion!
OtherDiscretelinks:
http://www.site.uottawa.ca/~lucia/courses/210110/
http://faculty.ucmerced.edu/mhyang/course/cse115/
http://www.cs.ucf.edu/courses/cot3100/spr2010/
The Topics
Belowarethetopicsfortheexam.ThislistwasprovidedbyArupontheCSwebsite,andIve
addedmynotes&tips.
ComputerSciencePartA
RecursiveCoding
i.Needaterminatingcondition
ii.Needanalgorithmfornonterminatingcase.
iii.Inparticular,youmustreduceaquestiontosmallerinstancesofthesamequestion.
iv.Donottrytothinkofaniterativesolution!!!
v.TowersofHanoisolutionandrecursion
vi.Permutation
vii.Floodfill
DaffsTips:
Itsunlikelytheywillaskyoutocodetheseexactproblems(suchasFloodfill),although
possible.Thereasonheasksyoutounderstandthisisbecauseifyouknowhowtodo
Floodfill,youcanfigureoutotherquestionstheymightaskyou.
Evenifyourenotsurehowtodoit,atleastwritedownsomethingtogetsomeeasy
points.Forexample,ifyoulookoverthegradingguidesforthepreviousexams,youll
noticeyouusuallyget2pointsjustforcheckingiftheheadofalinkedlistisnull.Doit!
Nevergiveupeasypoints.Manypeopleonlypassorfailtheexambyafewpoints.Every
pointmatters.
SummationsandAlgorithmAnalysis
i.Breakthemdownintomultiplesummationsifnecessary
ii.Evaluateeachofthoseusingsummationformulas.
iii.Rememberthatindicesofsummationareimportant.
iv.ThenintheformulaisJUSTavariable!!!
v.Derivingrecurrencerelationfromcode
vi.Usingiterationtosolverecurrencerelations
DaffsTips:
Justmakesuretodoalotofpracticeproblems.Youllunderstandthesebydoingthem.
Alsoforrecurrencerelations,IfoundJonathanslecturenotestobeagodsend.
MemorizethefiveSummationformulasfromSarahsCS1slides.Arupalsohasthe
formulasinhisnotes(healsohasa6thadditionformula).
i.Stacks
a.Convertinginfixtopostfixexpressions
b.Evaluatingpostfixexpressions
c.ArrayImplementation
d.LinkedListImplementation
ii.Queues
a.ArrayImplementation
b.LinkedListImplementation
Tips:
Infixandpostfixareprettyeasybecauseyoucanchecktheanswertomakesureit
works.Justdosomepracticeproblemsforconvertingtheminbothdirections.Also
reviewArupscodeonhowtoimplementstacksandqueues.
4.AdvancedDataStructuresTracing
i.BinaryTrees
a.Traversals
ii.AVLTrees
a.Insertion
b.Deletion
Tips:
ReviewthelecturestomakesureyouunderstandhowtheAVLrotationswork.Then
practice,practice,practice.Trygivingyourselfcomplicatedandweirdinsertion/deletion
casesandseeifyoucandothem.
iii.HashTables
a.HashFunctionProperties
b.LinearProbingStrategy
c.QuadraticProbingStrategy
d.SeparateChainingHashing
Tips:
Theseproblemsareusuallystraightforward.Justunderstandhowtheywork,thethree
differentstrategies,andtheBigOtimesandspacecomplexity.
iv.BinaryHeaps
a.Insertion
b.DeleteMin/Max
Tips:
YoutubehashelpfulvideosonHeapifyandbinaryheapsingeneral.
Conversions
i.Conversionfrombinarytodecimal.
ii.Conversionfromdecimaltobinary.
iii.Conversionbetweenbinary,octalandhex.
Tips:
Justpracticetheseandknowhowtodothem.Simpledivisionandmultiplication,really.
Theseareeasypointsifyougetasked.
ComputerSciencePartB
1.AlgorithmAnalysis
i.KnownDataStructures
ii.Best,Average,WorstCases
iii.Basedonvariousimplementations
iv.NewProblemAnalysis
Tips:
Studyandunderstandhowthesereallywork.Ifyoudo,youcanfigureouttheBigOin
yourheadandreasoning.Butjusttohelp,IdrecommendwritingtheBigOson
flashcardsandmemorizingthemtoo.
Timingquestions
i.Setupcorrectlywithanunknownconstant
ii.Solvefortheconstant.
iii.Usedirectformulatoanswerthequestion
iv.Forloopquestions,writeoutsummations
Tips:
Practicetheexamplesandmakesureyouknowhowsummationswork.Summations
mightlookweirdbutjustthinkofthemasaForloop.
LinkedListsCoding
i.Howtoallocatespaceforanewnode(malloc)
ii.WhentocheckforNULL
iii.Whatfreedoes
iv.Iterationvs.Recursion
v.Insertion
vi.Deletion
vii.StructuralModification
Tips:
Hopefullyyouhadalotofcodingpracticewiththesefromyourclass.ReviewArups
sampleprogramsifyouneedmorehelpunderstandinglinkedlists.
BinaryTreesCoding
i.Howtoallocatespaceforanewnode(malloc)
ii.WhentocheckforNULL
iii.Whatfreedoes
iv.Usingrecursionwithtrees
v.Computingsumofnodes
vi.Computingheight
vii.Othervariants
Tips:
Thesequestionsusuallyrequireyoutohaveagoodunderstandingofmovingthroughthe
differentlevelsofatree.OftentimesthequestionsrequireyoutousetheModoperatorto
knowifsomethingisevenorodd.
Recursionproblemsareusuallyfairlyshort.Ifyourecodinga20linesolution,youre
probablyovercomplicatingit.
Sorting
i.InsertionSort
ii.SelectionSort
iii.BubbleSort
iv.MergeSort(Merge)
v.QuickSort(Partition)
Tips:
Studyhowtheseworkandhowtocodethem.Theyusuallydontaskquestionsaboutthe
samesorttwiceinarow.SoiftheyaskedstudentstorunthroughasampleSelection
Sortonthelastexam,thenonthenextexamtheywillprobablyaskaboutBubbleor
Insertionsort.Butnothingisguaranteedsoknowthemall.
DiscreteStructuresPartA
SummationsandInduction
i.Useofstandardsummationrules+meaningofasummation.
ii.DivisibilityProblems
iii.MatrixProblems
iv.Otheranyassertionfornonnegativeints.
v.Howtoplugintoaninductivehypothesisandstep.
vi.Some"tricks"
vii.Howtodealwithinequalities
viii.StandardAlgebrarules
Tips:
HopefullyyouaregoodwithyourAlgebrabecausemanytimesthesequestionswill
requireanalgebratechnique,suchasCompletingTheSquare.Othercommonthings
likegroupingliketermsareoftenused.
Theseproblemsareusuallyworth15points,sotheyareimportant.Practiceandreadthe
textbookifneeded.
Logic
i.Meaningofand,or,not,implicationandcontrapositive,xor
ii.TruthTables
iii.LogicLaws
iv.LawsofImplication
v.Quantifiers(forallandthereexists)
Tips:
Youaregiventhetableoflawsfortheexam.Usethemanddoublecheckyourworkto
makesureyoureusingthecorrectlaw.
Sets
i.Defnofemptyset,subset,intersection,union,complement,setdifference,setproduct,and
powerset
ii.SetTables
iii.ProofbyContradiction
iv.DirectProof
v.DisproofbyExample
Tips:
TheRosentextbookandArupslecturesprovidealotofexamplesforthese.Ifyouare
givenaproblemthatcanbesolvedwithadirectproof,consideryourselfblessed.
YoumustunderstandhowproofsworkinordertodowellontheDSportion,asusually
therearemultiplequestionsthatdependonthistypeofreasoning.Donttakeproofs
lightly!
NumberTheory
i.Definitionofdivision
ii.Euclid'salgorithm(andextendedEuclid)
iii.UniquePrimeFactorization+Proof
iv.LeastCommonMultiple
v.ModularArithmetic
vi.ProofofanInfiniteNumberofPrimes
vii.Proofoftheirrationalityofsqrt(2)
Tips:
SometimestheNumberTheoryproblemscanbequiteeasy(likeasimpleGCDproblem)
orcanbeveryconfusing.Justpayattentiontowhatheisaskingyouandtrytothink
throughit.Thesearehardtoprepareforbecausetheycouldasksomanythings.
Althoughhelikelywontaskyoufortheexactproofoftheirrationalityofsqrt(2),the
reasonyoushouldstudyitisbecauseifyoucandothatone,youcanprobablydoothers
thathemightask.
Counting
i.Meaningofcombinationvs.permutation
ii.Sumprinciple
iii.Productprinciple
iv.Numberofsubsetsofaset
v.BinomialTheorem
vi.InclusionExclusionprinciple
vii.Countingbysubtractingfromthewhole
viii.CombinationswithRepetition
Tips:
Youhavetoreallythinkaboutwhatsgoingonandwhatthequestionisaskingfor.
Knowthefourformulas:
Combinationswithoutrepeat
Combinationswithrepeat
Permutationswithoutrepeat
Permutationswithrepeat
Seethishelpfulcalculator(alsoshowsformula):
http://www.mathsisfun.com/combinatorics/combinationspermutationscalculator.
html
Probability
i.SampleSpace
ii.TwoCountingQuestions
iii.InclusionExclusionPrinciple
iv.TreeDiagrams
v.ConditionalProbabilities
vi.BayesLaw
vii.BinomialDistribution
viii.IndependentEvents
ix.MutuallyExclusiveEvents
Tips:
IfyouvetakenStatisticsalready,itwillhelpyouwiththeseproblems.
Relations
i.Definitionofarelation
ii.Reflexive,irreflexive,symmetric,antisymmetric,&transitive
iii.Equivalencerelation
iv.PartialOrderingrelation
v.Relationcomposition
vi.Inversion
vii.Usesameprooftechniquesaswithsets
Tips:
Notipsexcepttojustpracticeandbesuretoprovideyourreasonalongwithyouranswer
ontheexamquestions.TheseareusuallysomeoftheeasiestpointsontheDSexam.
Functions
i.Definitionofafunction
ii.Domain,CoDomain,Range
iii.Inversion
iv.Injection,surjectionandbijection
v.FunctionComposition
Tips:
InversionisprettyeasywiththetrickofswappingtheXandYvariables,solving,andthen
swappingthembackaround.YoucanfindexamplesofdoingthisonYoutube,searchfor
inversefunctions.
GeneralAdvicefromArup
A.Dowhatyouthinkaretheeasyquestionsfirst.
B.Onlywritewhatyouthinkyouknow,dontmakestuffup!!!
C.Dontforgettothink.Thistestshouldnotbemechanical,trytobecreative.Ifyouseea
questionyouveneverseenbefore,thinkaboutsubproblemsthatmaybeeasiertoattack.See
whatyoucandeducebasedonthegiveninformation,evenifthequestiondoesntaskforit.
D.Readoverallofyourproofswhenyouaredone.
Makesureyouarespecific.Seeifyourproofsmakesense.
Flash Cards
InjectiveFunction(onetoone):
f(a)=f(b)>(a=b)foralla&bindomainf
Nevermorethanoneincomingarrow,butnotalwaysanarrowfromlefttoallofrightvalues
ifA>Bthen|A|<=|B|
Surjective(onto):
ForallbinB,thereexistsanainAsuchthatf(a)=b
Multiplearrowscangotoananswerontheright,andeveryvalueonrightwillhaveanarrow
goingtoit.
ifA>Bthen|A|>=|B|
Bijective:
BothinjectiveandSurjective.Onetooneandonlyfunctionstohaveinverses
ifA>Bthen|A|=|B|
Whatvalueisineveryset:
Null
A={1}B={2}
AUB=?:
{1,2}
A={1}B={2}
AnB=?:
{NULL}
Assume:p,p>q
Thenq:
ModusPonens
Assumep>q,q>r
Thenp>r:
lawofsyllogism
Assumep>q,p
Thenq:
ModusTollens
A|Bmeans:
AdividesBsoAisafactorofB
A|BandA|Cimplies?:
A|(B+C)
WhatarethethreepartsofInductions:
BaseCase,InductiveHypothesis,InductiveStep
A=R(modB)isequivalentto:
A=Bn+R
Reflexive:
aRaforeveryelementainA
Irreflexive:
adoesnotRaforeveryelementainA
Symmetric:
ifaRb>bRaforalla,binA
Antisymmetric:
ifaRbandbRa>a=bforalla,binA
Transitive:
ifaRb&bRc>aRcforalla,b,cinA
[x]={a|aisanelementofA^aRx}isanexampleof:
Equivalenceclasses
BigObestandworstcaseofInsertoflinkedlist:
Best:O(1)
Average:O(n)
Worst:O(n)
BigObestandworstcaseofQuicksort:
Best:O(nlogn)
Average:O(nlogn)
Worst:O(n^2)
BigObestandworstofhashtableaccessofvalue:
Best:O(1)
Worst:O(n)
BigObest,average,worstofbinarytreesearch:
Best:O(1)
Average:O(lgn)
Worst:O(n)
BigOofBubblesort:
Best:O(n)
Average&Worst:O(n^2)
BigOofMergesort:
O(nlgn)
Definitionofsetdifference:
n(negCUnegB)becomes(CnB)
Definitionofimplication:
(q>r)==(qvr)
Equivalencerelation:
reflexive,symmetric,andtransitive
PartialOrderingRelation:
Reflexive,Antisymmetric,andtransitive
BinarySearchonsortedlist:Averageandworstcase,Spacetimecomplexity:
Avg:O(logn)
Worst:O(logn)
Spacecomplexity:O(1)
Quicksort:
Best:O(nlog(n))
Avg:O(nlog(n))
Worst:O(n^2)
Spacecomplex.worst:O(n)
Mergesort:
Best:O(nlog(n))
Avg:O(nlog(n))
Worst:O(nlog(n))
Spaceworst:O(n)
Heapsort:
Best:O(nlog(n))
Avg:O(nlog(n))
Worst:O(nlog(n))
Spaceworst:O(1)
BubbleSort:
Best:O(n)
Avg:O(n^2)
Worst:O(n^2)
Space:O(1)
InsertionSort:
Best:O(n)
Avg:O(n^2)
Worst:O(n^2)
Space:O(1)
SelectionSort:
Best:O(n^2)
Avg:O(n^2)
Worst:O(n^2)
Space:O(nk)
BucketSort:
Best:O(n+k)
Avg:O(n+k)
Worst:O(n^2)
Space:O(nk)
RadixSort:
Best:O(nk)
Avg:O(nk)
Worst:O(nk)
Space:O(n+k)
HowdoesSelectionSortwork?:
1.Findsthesmallestelementinthelistandswapsitwiththeelementinthefirstposition.
2.Thenitfindsthesecondsmallestelementandswapsitwiththeelementinthesecond
position.
3.Itdoesthisuntilwereachthelastposition.
HowdoesInsertionSortwork?:
1.Startingwiththesecondelement,yougoonebyoneandinsertit(byswapping)intothe
alreadysortedlisttoitsleftinthecorrectorder.
2.Sobythetimeyoureachtheendofthelist,itwillputthelastelementwhereitshouldbeand
thenthelistissorted.
HowdoesBubbleSortwork?:
1.Goinglefttoright,youcompareconsecutiveelements.
2.Whenevertwoareoutofplace,youswapthem.Attheendofasingleiteration,themax
elementisinthelastspot.
3.SoJoe>BobwouldbeswappedtoBob>Joe.
4.Thisrepeatsntimes.
5.Oneachpass,themaximalelementismovedtoitscorrectspotattheend,asifthe
maximumis"bubblingup".
HowdoesMergeSortwork?:
1.Arrayscanbebrokenintohalftoformtwosmallerarrays.Youcancontinuetodothisif
needed.
2.Whenyouhavetwoarrays,keeptrackofthesmallestvalueineachonethathasn'tbeen
placedinorderinthelarger"Merged"arrayyet.
3.Comparethetwosmallestvaluesfromeacharray,placethesmallestinnextlocationinLarge
array.
4.Thenyouadjusttheminimumvaluemarkerinthearraythesmallestelementwasremoved
from.
5.Continueuntillarge"Merged"arrayisfull.
HowdoesQuicksortwork?:
1.Randomlypickapivotvalue(orbest:pickthe1st,last,andmiddleelement...andthengowith
themedianvalue)
2.Comparealltherestoftheelementstothisvalue
3.Iftheyaregreaterthanthisvalue,putthemtotherightofit.
4.Iftheyarelessthanthisvalue,putthemtotheleft.
5.Puta"Low"counteratthefirstelement,"High"counteratthelast
6.AdvancetheLowforwarduntilavaluehigherthanpivotisfound,andadvancetheHigh
backwarduntilavaluelowerthanpivotisfound.
7.Whenthesetwoconditionsaremet,swapthesenumbersandrepeattheprocess.
8.WhentheLowandHighcounterlineup,swaptheirvaluewiththepivot.
9.Nowrepeattheprocessforeachpartitiontheleftpartandrightpart.
Ingeneral,forksuccessesinnBernoullitrialswehaveaprobabilityof:
C(n,k)*p^k*q^(nk)
Anequivalencerelationisarelationthatis:
reflexive,symmetric,andtransitive
WhatisOpenAddressinginaHashtable?:
Everyhashtableentrycontainsonlyonekey.Ifthereisaconflict,weuseLinearProbingor
QuadracticProbingtoplacethenewkeyintoanemptyslot.
WhatisSeparateChaininginaHashtable?:
Everyhashtableentrycontainsapointertoalinkedlistofkeysthathashtothesameentry.
WhatisLinearProbing?:
Theprobingcontinuessequentiallythroughthetableandwrapsafterthelastslot(slotm1)to
thebeginning(slot0).
h(k,i)=(h(k)+i)modm,wheremisthesizeofthetable
WhatisQuadraticProbing?:
Similartolinearprobingexceptitexaminescells1,4,9andsoonawayfromtheoriginalprobe
pointbecauseitsformulahasi^2
h(k,i)=(h(k)+i^2)modm,wheremisthesizeofthetable.
WhattwoconditionsmustbemettoensureQuadraticProbingalwaysfindsanempty
location(ifoneisavailable)?:
ThetablesizemustbeaprimenumberANDthetablemustbeatleasthalfempty.Otherwiseit
couldendupinaloop,neverabletofindanavailablespoteventhoughoneexists.
Howdoyouexpandahashtableifneeded?:
1.Pickaprimenumberthatis~2xaslargeasthecurrenttablesize
2.Usethisnumbertochangethehashfunction
3.RehashALLthevaluesalreadystoredinthetable
4.Thenyoucannowbeginhashingnewvaluestobestored.
Howarelinkedlistsusedinseparatechaining?:
Inacollisionyoujustinsertnewitemstothefrontofthecorrespondinglinkedlist.
Abinarytreeisfullif:
eachnodeiseitheraleaforhasexactlytwochildnodes.
Abinarytreeiscompleteif:
alllevelsexceptpossiblythelastarecompletelyfull,andthelastlevelhasallitsnodestotheleft
side
ForAVLtrees,whenchoosingthenodesA,B,andC,remembertheyarealways...:
onthelongestpathtothebottomofthetree.E.g.thismeansthatwhenwefindanimbalanced
nodeafterdeleting,thenodetotheoppositesideisguaranteedtobedownthelongerpath
Adescendinglistwouldbeveryslowinwhatkindofsort?:
Insertionsort
Whenyoudeletefromaminheap,youdeletetheroot(top)node.Whatdoyoureplaceit
with?:
Youreplaceitwiththelastlinkinthetree,i.e.thelastnodeaddedinthetreeorarray.Thenyou
percolatedown(ifneeded)byswappingwiththeminimumchilduntilitisintherightspot.