Documente Academic
Documente Profesional
Documente Cultură
byEvanHahn+ScottGodbold+BradHekman+AlexIhlenburg+RyanYezman+Matt
Schulte+LuluTang+AndyModell+KevinByung+DavidBrownman+OttoSipe+Yaoyun
Shi+ThomasLovett+SeanHacker+MikeCuskley&DanielNees
(addyournameshereifyouhelped!)
Feelfreetoeditifyouthinkyouhavesomethingtoadd,butpleasedonotruinthis
voluptuous document.
Thisstudyguideisfreelicenseinthepublicdomain.Itsaccuracyisnotguaranteed.
EXAMINFO
Youcanbring3singlesidedsheets
"Inaddition,inyoursolutionsyouareallowedtoquotewithoutproofanyresultsproved
inthelectures,discussionsections,homework,thesampleexam,andthetextbook."
PROPOSITIONSANDOPERATIONS
Propositioneithertrueorfalse,butnotboth
p=negationofp
pq=and(rememberthatisliketheAin"AND")
pq=or
pq=ExclusiveorXORonlyonecanbetrue
Tautologyalwaystrue
Contradictionalwaysfalse
Distributivelaws
p(qr)(pvq)(pvr)
p(qvr)(pq)v(pr)
DeMorgan'sLaws
(pq)pvq
(pq)pq
1
CONDITIONALS
pq:ifp,thenq
TF=Feverythingelseistrue
Englishwaystoexpressconditionals
"ifp,thenq"
"ifp,q"
"pissufficientforq"
"qifp"
"qwhenp"
"anecessaryconditionforpisq"
"qunlessp"
"pimpliesq"
"ponlyifq"
"asufficientconditionforqisp"
"qwheneverp"
"qisnecessaryforp"
"qfollowsfromp"
Logicalequivalences
pqpvq
pqqp
pvqpq
pq(pq)
(pq)pq
(pq)(pr)p(qr)
(pr)(qr)(pvq)r
(pq)v(pr)p(qvr)
(pr)v(qr)(pq)r
Biconditionallogicalequivalences
pq(pq)(qp)
pqpq
pq(pq)v(pq)
(pq)pq
RULESOFINFERENCE
Forpropositionallogic
[p(pq)]q
[q(pq)]p
(modusponens)
(modustollens)
2
[(pq)(qr)](pr)
[(pvq)p]q
p(pvq)
(pq)p
[(p)(q)](pq)
[(pvq)(pvr)](qvr)
(hypotheticalsyllogism)
(disjunctivesyllogism)
(addition)
(simplification)
(conjunction)
(resolution)
Forquantifiers
xP(x)P(c)(universalinstantiation.Example:"Allwomenarewise",therefore"Lisa
iswise.")
P(c)forarbitrarycxP(x)(universalgeneralization)
xP(x)P(c)forsomec(existentialinstantiation)
P(c)xP(x)forsomec(existentialgeneralization)
QUANTIFIERS
xP(x)=P(x)istrueforeveryxonthedomain
xP(x)=thereisanxonthedomainforwhichP(x)istrue
!xP(x)=thereisONLYONExonthedomainforwhichP(x)istrue
DeMorgan'sLaws
xP(x)xP(x)
xP(x)xP(x)
Nestedquantifiers
xxQ(x)x(xQ(x))
Quantifyingtwovariables
AhelpfulPowerPoint
xyP(x,y)yxP(x,y)=truewhenP(x,y)istrueforeverypairofxandy
xyP(x,y)=truewhen,foreveryx,thereisayforwhichP(x,y)istrue
xyP(x,y)=truewhenthereisanxforwhichP(x,y)istrueforeveryy
xyP(x,y)yxP(x,y)=truewhenthere'sapairx,yforwhichP(x,y)istrue
PROOFS
Proofbyexhaustion:tryeverything(onlyworkswithafinitenumberofpossibilities)
Proofbycases:youcanbreakthingsintogroupsandshowthatcertaingroupswork
Proofbyimplication
AssumePistrue
AssumeP,PthenQ,thereforeQ
HoldsbecauseifPistrueyougetQandifPisfalsethenQis
automaticallyimplied
3
AfteryouproveQitisnolongersafetoassume,Pstillholds
Provethecontrapositive
AssumeNotQshowthatitimpliesNotP
Proving"ifandonlyif"
Proveeachimpliestheother
PimpliesQANDQimpliesP
Constructachainofiffs
ShowPiffRiffSiffQsoPiffQ
Proofbycontradiction
ShowthatifthepremiseisTorFthensomethingFwouldbeT
Example:ShowthatifPisfalse,then0=2since0!=2Pmustbetrue
SETS
Acollectionofofobjectscalledelementsgroupedtogether
Orderingisnotimportant,justwhichelementsarecontained(eg,{x,y}isthesameas
{y,x})
xDshowsxisanelementofD
=theemptyset={}
N=naturalnumbers={0,1,2,...}
Z=integers={...2,1,0,1,2,...}
Z+=positiveintegers={1,2,3,4,...}
Q=rationals
R=reals
R+=positivereals
C=complexnumbers
SetscancontainothersetsdenotedSTshowingSisasubsetofTorallthe
elementsinSareinT
Unioning()twosetscombinesalltheelementsoftwosets(additive)
Intersection()createsasetcontainingallelementscontainedbybothsets
Subtraction()createsasetcontainingallelementsof1stsetexcepttheonesinthe
2ndset.Example:ABcontainsalltheelementsofAexcepttheonesthatareinB.
Thecomplementofasetiseverythingexcepttheelementsinthatset
Asethasacardinalityequaltothenumberofelementsintheset
Example:S={1,2,3}|S|=3
S={{1,2,3},{4,5,6}}|S|=2
S={{},1}|S|=2
S={,1}|S|=2//note:ifiscontainedintheset,thenitcountsasan
element.Ifthesetitselfisempty,thanthecardinalityis0(seebelow).
S=|S|=0
Powerset
Thesetcontainingallsubsetsofaset(Iknow,kindofstrangewording)
ex.BP({1,2})iffB={{},{1},{2},{1,2}}
Cardinalityofapowersetis:|P(S)|=2^|S|
Cartesianproductofsets
4
Givesallpossiblesetsofwhichthefirstelementcomesfromsetoneandthe
secondelementcomesfromset2
Notationfordefiningaset
A={nR|x^33x+1>0}
Setequality
Twosetsareequalifandonlyifeveryelementinonesetisintheotherand
visaversa
INDUCTION
Principle
P(n)isyourpredicate
IfP(0)istrueandP(k)impliesP(k+1)thenP(n)istrueforallnintheset
InductionTemplate
Stateyouareusinginduction
DefineyourpredicateP(n)
ProvethatP(0)istrue(BaseCase)
AssumeP(n)istrue
ShowthatP(n+1)istrue
StrongInduction
P(0)istrueandP(0)throughP(n)implyP(n+1)
FUNCTIONS
AfunctionisamappingfromdomainAtocodomainBsuchthatforanyoneinput
therecanonlybeoneoutput
Denotedf:ABorf(A)={y=f(x)|xA}
Onetoone/injectiveXisonetoonewithYifeverymappingtoYhasexactlyONE
valueinXthathitsit
Onto/surjectiveXisontoYifthereexistvaluesinXsuchthatmappingthemontoY
willhiteveryvalueinsideofY
Bijectiveitgoesbothways:ontoandonetoone
OnetoonecorrespondenceAfunctionisaonetoonecorrespondenceifitis11
andonto
Inversefunctionsafunctionf1(x)themapsbontoaiffthefunctionf(x)mapsfroma
tob.Thisonlyworksiffisontoand11.
CountableainfinitesetwithaonetoonecorrespondencewiththesetofNatural
numbers
CompositefunctionsMappingatocthroughasetoftwofunctionsthatmapatob
andthenbtoc,denotedfog.Otherwisewrittenasf(g(a)).
ALGORITHMS
Algorithmfinitesequenceofpreciseinstructionstoperformacomputation
Searches
Linearsearchstartatthefront,bruteforceuntilyoufindit.Worstcase:O(n)
Binarysearchstartatthemiddleofasortedlist.Ifyouretoohigh,searchtheleft
halfofthelist.Ifyouretoolow,searchtherighthalfofthelist.Worstcase:O(log(n))
Sorts
Bubblesortswitchadjacentvaluesoverandoveragainuntilyoudontswitchno
more.Anotherwaytothinkaboutbubblesortis:findthebiggestelementandputitat
theend,thenlookforthesecondbiggestelementandputitonefromtheendandso
on.
WorstcaseO(n2),bestcaseO(n).
Insertionsortplaceeachelementfromtheunsortedlisttothecorrectplaceinthe
sortedlist.WorstcaseO(n2),bestcaseO(n).
Haltingproblem
Procedurethatcannotbesolvedwithanalgorithm.
H(P,I)definesHasaprocedurewhichtakesintwoarguments.PisaprogramandIis
argumentstoP.HreturnstrueifPwillhaltwithargumentsI,orfalseifPloopsforever
ProofthatH(P,I)cannotbesolvedwithaprocedure:defineK(P)ashaltingifH(P,P)(
aprogramcantakeitselfasanargument)returnsfalse(runforever).K(P)runsfor
everifH(P,P)returnstrue(halting).
IfwepassKitselfK(K).IfKhaltsthenH(K,K)wouldvesaidtheKwouldrunforever
andalsoifKrunsforeverH(K,K)wouldvesaidthatKhalts.Thus,creatinga
contradiction.
SEQUENCES
Asetthatfollowsapattern
Recurrencerelationsexpressesthevalueofanasafunctionofthepreviousterm
(ana).Alwayshasabasecaselikea0=1,a1=1,etc.
Commonpatternsforsequencetermstofollowa+dn,arn,n2,n3,n4,2n,3n,n!,fibonacci
6
SUMMATIONS
Moreoftheseformulascanbefoundusinggoogleifthisdoesntseemcomprehensive
enough.
COSTSOFACOMPUTATION
BigO,big,big
BigOupperboundonthegrowthofthefunction
f(x)=O(g(x))thereforeC*g(x)f(x)
BigOmegalowerboundonthegrowthofafunction
f(x)=(g(x))thereforeC*g(x)f(x)
BigThetaafunctionthatdescribesthesamegrowthorderasfunctionyouare
observing
f(x)=(g(x))thereforeC1f(x)=O(g(x))&C2f(x)=(g(x))
Onlymattersasthefunctionprogressestoinfinity,youareallowedtosayforallx>k
WhendisprovingallbigOorbig,shownosuchwitnessespairs(k,C)exist
Algebrarelations
Addition
f(x)isO(g(x))&e(x)isO(h(x))then(f+e)isO(max(g(x),h(x)))
Scalarmultiplication
Whenf(x)isO(g(x))andthereisaconstantkthenk*f(x)isO(g(x))
Product
f(x)isO(g(x))&e(x)isO(h(x))then(f*e)isO(g*h)
Todetermineafunction'sbigOyoumustfindthesumequivalentvalueand
determiningwhatbindsit
Ifthelimitexistsandisfiniteasxgoestoinfinityoff(x)/g(x)thenf(x)O(g(x))
ifthelimitisinfinite,thenf(x)O(g(x))
RecurrenceRelations
7
f(n)=a*f(n/b)+c
O(n^log_b(a))ifa>1
O(log(n))ifa=1
f(n)=af(n/b)+cn^d[aka...themastertheorem]
O(n^d)ifa<b^d
O(n^d*log(n))ifa=b^d
O(n^(log_b(a)))ifa>b^d
Tractability
Aproblemisconsideredtractableifthealgorithmtosolvetheproblemhas
polynomialorlesscomplexity
Aproblemisconsideredintractableifthealgorithmtosolvetheproblemhad
exponentialorhighercomplexity
Aproblemisconsideredunsolvableifnoalgorithmsolvestheproblem.For
example,theHaltingproblem.
COUNTING
InclusionExclusion
|AB|=|A|+|B||AB|
|ABC|=|A|+|B|+|C||AB||AC||BC|+|ABC|
CartesianProduct
S=S1S2...Sn
|S|=|S1||S2|...|Sn|(whetherdisjointornondisjoint)
Composite:notprime
Pigeonholeprinciple
IfNpigeonsnestink<Nholes,thenatleastoneholewillhavetwoormorepigeons.
Generalizedpigeonholeprinciple
IfNobjectsareplacedintokboxes,thenthereisatleastoneboxcontainingat
leastCEIL(N/k)objects.
Purifiedpigeonholeprinciple(EWD)
Foranonempty,finitebagofnumbers(andbagsallowsrepetitions),the
maximumvalueisatleasttheaveragevalue.
BINOMIALTHEOREM
Definition
Similartothemultinomialtheorem,whichexpandsitouttoanarbitrarymelements
8
COMBINATIONS&PERMUTATIONS
Combinations/choose(akabinomialcoefficient):orderdoesnt
matter
C(n,k)
Thenumberofwaystochoosekobjectsfromnobjectsiforderdoesn'tmatter
Forexample,youwanttopickateamof5from20peopleorderdoesn'tmatter,so
it'sC(20,5)
n!
C(n,k)= k!(nk)!
(andyoucanseeitprettieronWikipedia)
Withrepetitionallowed:C(n,r)=
(n+r1)!
r!(n1)!
Permutations:ordermatters
P(n,k)
Thenumberofwaystochoose(pick)kobjectsfromnobjectsifordermatters
Forexample,ifyouwanttopickthetop10songsfrom200,ordermatters,soit's
P(200,10)
P(n,k)=n!/(nk)!(andyoucanseeitprettieronWikipedia)
Withrepetitionallowed:P(n,k)= nk
PLACINGBALLSINURNS
Placingnballsintomurns(forS(n,m),seebelow):
balls
urns
#balls/urn
#solutions
labeled
labeled
any
mn
labeled
labeled
<=1
P(m,n)
labeled
labeled
>=1
m!S(n,m)
labeled
labeled
kthurnholdsnk
balls
n!/(n1!n2!
nm!)
unlabeled
labeled
any
C(n+m1,m
1)
unlabeled
labeled
<=1
C(m,n)
labeled
unlabeled
>=1
S(n,m)
labeled
unlabeled
unlabeled
unlabeled
any
>=1
S (n, k )
k=1
Pm(n)
9
Stirlingnumbersofthesecondkind
S(n,k)=theamountofwaystosplitndistinguishableobjectsintokindistinguishable
bins
Forexample,ifyouhave4employeesandwanttoputtheminto2offices(andyou
can'tdistinguishtheoffices),that'sS(4,2)=7differentwaystodothis
There'sanuglyformulawhichyoumightwannawritedown
It'susuallybesttouseachart,whichyoumightalsowanttowritedown
PROBABILITY
StartswithadefinedsamplespaceSandaneventEinthatsamplespace
probabilityofEisp(E)=|E|/|S|
0P(E)1
P(notE)=1P(E)
P(E1E2)=P(E1)+P(E2)P(E1E2)
Methodforprobability
Findthesamplespace
Defineeventsofinterest
Determineoutcomeprobabilities
Computeeventprobabilities
BAYES'THEOREM
P(E|F)=theprobabilityofE,givenF
P (E|F ) =
P (F |E)P (E)
P (F |E)(P (E)+P (F |G)(P (G))
GisthecomplementofE
Moregenerally, P (E|F ) =
P (F |E)P (E)
P (F )
.P(F)maybegivenoreasiertodetermine.
IfyouhaveP(F)=,thentheyoucanuseasimplerversion:P(E|F)=P(F|E)/[
P(F|E)+P(F|Ecomplement)]
EXPECTATIONandVARIANCE
Expectedvalue=E(x)
X(s)isarandomvariable...
E(x)=P(si)X(si)
Expectationsarelinear,whetherornotXiareindependent
Usefulinprovingbasicpropositions
E(X1+X2)=E(X1)+E(X2)
E(aX+b)=aE(X)+b
10
TotalExpectations
E(R)=E(R|Ai)X(Ai)
DeviationisX(s)E(x)howeverthisisnotveryusefulandisoftensquared
Variance
Standarddeviation=V(x)
wherep=probability,x=value,mu=E(X)
RELATIONS
Reflexiverelationsyourefriendswithyourself.(A,A)
Symmetricrelationsmarriages.{(A,B),(B,A)}
TransitiveifIvetouchedherhand...{(A,B),(B,C),(C,A)}.(C,A)istransitive.
Antisymmetricif(A,B)and(B,A),thenA=B.(Thatistosay,theonlysymmetry
allowedisreflexiveness.)
Equivalencerelationsaretransitive,symmetric,reflexive
EquivalenceClasssetofelementsrelatedtoa.denoted:[a]
WarshallsTheoremusedtofindapathfromvitovj.ExcellentnotesonWarshalls.
HereisanicelittledemonstrationtocomplementLulus:Warshall
3
Complexity: 2n
PartiallyOrderedSetsorposetarereflexive,antisymmetric,transitive
Givesasetandarelationsharedbytheset,thesecaninclude<,>,=,>=,<=,
|,andmanymore.
WellOrderediftheSfollowsthegivenrelationandeverynonemptysubset
hasaleastelement(noelementsbranchfromit)andifitstotallyordered.
HasseDiagramsshowsaposetthatiswellordereddoesnotshowreflexiveness,or
directionoftheset.
MaximalElementelementsnotunderanyotherelements
MinimalElementelementnotaboveanyelement
GreatestElementeveryelementinthesetislessthanthiselementuniquewhenit
11
exists.
LeastElementeveryelementisgreateruniquealso.
LatticeAposetinwhicheverytwoelementshavealeastupperboundanda
greatestlowerbound.Essentiallyeverypairofnodeshaveaspecificnodethatisa
sharedgreatestorlowestboundthisnodecannotbeonthesamelevelasother
nodesthataregreatestbounds.
Matrixstuff
AdjacencyMatrixHasa1intheijthpositionifvertexiisadjacenttovertexj.
Otherwiseithasa0.(Note:youalwaysreadamatrixinrowcolumnordersotheijth
entryistheithrowandthejthcolumn)
IncidenceMatrixHasa1intheijthpositionifvertexiisconnectedtoedgej.
Otherwise,ithasa0.Thisonerequirestheedgestobelabelled(e1,e2,etc.).
BooleanMatrixAmatrixcontainingonlyzeroesandones,wherezeroesrepresent
falseandonesrepresenttrue.Thisdiffersfromaonezeromatrix.
Composition
GRAPHS
SimplegraphsGraphsthatdonothaveselfloopsorparalleledges.
Vertexapointthatrepresentsaplaceonthegraph(anode)
isolatedvertexofdegree0
pendantiffdegree1
Edgeapathattachingtwovertices
Degreedegreeofvertexvisthenumberofverticesadjacent(itisconnectedto)toit
Degreesequenceanonincreasinglistofvertexdegrees
Specialgraphs
CompletedenotedKnwithnverticesallpairsareconnected.
nvertices
n(n1)/2edges
CycledenotedCnnverticesthatformaclosedpaththatstartsandendson
thesamepoint
12
Thoseareallvalidcycles^
nvertices
nedges
WheeldenotedWnnverticesthatformedbyconnectingasinglevertextoall
theother(n1)vertices
n+1vertices
2nedges
BooleancubedenotedQnwith2nverticesindexedbynbitstringswhere
eachnodediffersitsadjacentnodesby1bit.
2nvertices
n*2n1edges
Regulargraphalldegreesarethesame
example:2regular:allverticeshaveadegreeof2
PetersonGraph
ChromaticNumber:3
3connected
BipartitedenotedKn,mwherethereexistsnoedgeinsidethegraphanditcanbe
separatedintotwosidenandm,isconsideredcompleteifallpairsbetweennandm
areconnected.Itis2colorable.
Chromaticnumbertheminimumnumberofcolorsneededtocoloragraphsuch
thatnotwoadjacentnodeswillhavethesamecolor.
InducedsubgraphPartofagraph.Anedgeinducedsubgraphisalltheedges
listed,aswellastheirendpoints.Avertexinducedsubgraph(thisisthenormalkind)is
alltheverticeslisted,alongwithanyedgesthatgobetweenthem.
MatchingasetofedgesonGsuchthatno2setsshareavertexincommon
Perfectmatchingmatchingwithn/2edges(mustbeanevenamountofverticesfor
aperfectmatching.)
Petersengraph:
edgeconnectivity:3
vertexconnectivity:3
Connectivity
13
Edgetheminimumnumberofedgesremovingwhichwoulddisconnectthe
graph,shown(G)
Vertextheminimumnumberofverticesremovingwhichwoulddisconnect
thegraph,shown(G)
Eulerianpath&cycleapaththatvisitseachedgeonceandonlyonce,itiscalleda
cycleifdoingsomakesacompletecycle
AgraphhasanEulerianpaththatisnotacycleifandonlyifthereareprecisely
twoverticesofodddegree,thispathmuststartononeofthosenodes.
AgraphhasanEuleriancycleifeveryvertexhasanevendegree.
Hamiltonianpath&cycleapaththatvisitseachvertexonlyonce,againisacycleif
doingthisalsomakesacompletecycle.
OrestheoremAgraphGonnverticesisHamiltonianifdeg(u)+deg(v)>=nforall
nonadjacentverticesuandv.
uandvmustnotbeconnected
DiracstheoremAgraphGwithnverticesisHamiltonianif:
Graphissimple
n>=3
degreeofeachvertexisatleastn/2
Stablemarriage:thepreferencerankingmatrixwediscussedatlecture(Allwomen
havethesamelist1,2,..,n,andManislistisi,i+1,...,n,1,2,..,i1).
HallsTheorem:abipartitegraphG=(S,T,E)hasamatchingthatmatchesallvertices
inSiffforallsubsetsWofS,thecardinalityoftheneighborhoodWisgreaterthanor
equaltothecardinalityofW
Proofsketch:keepincreasingthesizeofthematchingthroughaugmenting
path
criticalobjectinproof:augmentingpath
keyfactnumerouno:ifPisanaugmentingpathwithrespecttoamatchingM,
thenMXOPisamatchingand|MXOP|=|M|+1
MXOP=(Pintersect[not]P)union([not]MintersectP)
keystepintheproof:underthemarriagecondition,thereisalwaysan
augmentingpath
intuition:otherwisethesetofverticesreachedbyanalternatingpath
violatesthemarriagetheorem
GaleShapleyTheorem:thedeferredacceptancealgorithm
AcquaintanceshipGraphapathbetweentwopeopleifthereisachainofpeople
linkingthesepeople.Twopeoplewhoareadjacenttoeachotherknoweachother.
AlternatingPathisapathinwhichtheedgesbelongalternativelytothematching
andnottothematching
AugmentingPathsanalternatingpaththatstartsfromandendsonfree(aka.
unmatchedorexposed)vertices.Eachtime,augmentingpathincreasesthetotal
numberofmatchingby1.
Isomorphicchangingthegraphsappearancewithoutchangingthegraphitself.Say
youhaveagraphGandanedgeexistsbetweentwoverticesv1,v2inG.Ifyou
transformthegraph,s.t.v1=xandv2=y,inanewgraphG,thanandanedgeexists
betweenx,yinG.
i)theyhavethesamenumberofedges
ii)theyhavethesamenumberofvertices
iii)theyhavethesamedegreesforallvertices
14
iv)theyhavethesamecircuitsofsamelength
Everyacyclic(nocycles)graphG=(V,E)has|V||E|connectedcomponents
HandshakeTheorem:sumofdegrees=twicethenumberofedges
agraphis2regulariffitsavertexdisjointunionofsimplecycles
forallacyclicgraphs:thenumberofconnectedcomponents+thenumberofedges=
thenumberofvertices
meaningofthepowersoftheadjacencymatrix:theuventryofthekthpoweristhe
numberofuvpathsoflengthk
EXAMPLEPROBLEMS
Q:MontyHallproblem:3doors,onewithacarandtwowithgoats.Youchooseone
withoutopeningitandMontyshowsyoubehindadifferentdoor,onethathasagoat.
Shouldyouchangeyourdoor?
A:Yes.Why?Whenyouchoosefirst,yourchancesare,andsoyourchancesofbeing
wrongare.ButwhenMontyeliminatesadoorthechancethatthedooryoupickedisstill,
andso1=isdistributedacrosstheremainingdoors,inthiscase1door.Soisthe
probabilitythattheremainingdoorhastheprize.
A2:Anotherwaytothinkaboutthis(thatIfoundmorehelpful),isthinkinsteadthatyoure
pickingasinglecarfrom50doors.Youpickdoor42,andMontyopens48otherdoors(allof
whichhavegoats),leaving#1unopened.Now,thechancesofyouhavingpickedthecorrect
doororiginallywere1/50.Theresa49/50chancethatthecarisintheothersetofdoors.The
factthattheyrenowopenonlychangesthefactthattheresa49/50chancethatthecaris
behinddoor#1(asopposedtotheother48possibilities),soyoushouldswitch.
Q:Hatcheckproblem:Youcheckyourhatin,butthehatmanforgottoput
numbersonthehats.Whatistheexpectednumberofpeoplethatgettheirown
hatback?
A:1.Why?Expectationsarelinear.X=X1+X2+X3+X4+X5....+Xn.E(Xi)=1/n.You
canaddupthechancesofeachpersongettingtheirhatbacktogetheexpected
number.Summationof(1/n)fromi=1ton,whichis1.[Forexample3people...1/3+
1/3+1/3=1]
Q:Ifyouthrow2dice,whatistheexpectednumberofthrowsbeforeyougetsnake
eyes.
A:36.Why?Thetotalnumberofways2diecanlandis36,andsnakeeyesonlyappears
in1ofthose36.So1/p=36,p=1/36
Q:TheSAThasameanof500andstandarddeviationof100,whatdoes
Chebyshev'stellusaboutgettingascoregreaterthan700?
A:1/8.Why?P(SAT)>=700=P(SAT>=700or<=300)=V(X)/r^2=*
(100^2)/(200^2)=1/8Theisbecausewewantjustscores>700notlessthan300.100=
thestandarddeviationandthe200comesfromX(s)E(X)whichhereis700500.
15
Q:a)Whatistheprobabilitythattwopeoplechosenatrandomwerebornduringthe
samemonthoftheyear?b)Whatistheprobabilitythatinagroupofnpeoplechosen
atrandomthatthereareatleasttwoborninthesamemonthoftheyear?c)Howmany
peoplechosenatrandomareneededtomaketheprobabilitygreaterthan1/2thatthere
aretwopeopleborninthesameyear.
A:a)1/12.Thereare12monthsintheyear,andbeingbornisanindependentevent.Thatis,
theprobabilitythatyouwereborninacertainmonthdoesntdependontheprobabilitythat
anotherindividualwasborninthatsamemonth.Sincethereisonlyonewayfortwopeopleto
bebornonthesamemonththeprobabilityis1/12.
b)Sameasbirthdayproblem.
c)5.???
Q:a)ProvethatS(n,n1)=C(n,2)forn>=2b)ProvethatS(n,2)=2n11,n>=2
A:a)BythePigeonholePrinciple,aplacementmusthave2ballsinthesameurn,whileby
therequirementthatnournisempty,eachoftheotherurnscontainsprecisely1ball.Thusa
2placementuniquelydetermineapairofballs.Converselyapairofballsuniquelydeterminea
placementinwhichthetwoballsinthepairareinthesameurnandothersintheirotherurn.
ThusthereareC(n,2)placements.
b)EachnonemptypropersubsetAsubsetofnuniquelydeterminesaplacementwithAin
oneurnandB=notAintheotherurn.Foreachplacementprecisely2propersubsetsAand
notAwouldgivethesameplacement(bysettingAtobethesetofballsofeitherurn).Thus
thenumberofplacementsis(2n2)/2=2n11
Q:a)Supposewehaveatrainingsetof10,000spammessagesand5000nonspam
messages.Thewordenhancementappearsin1500spammessagesand20nonspam
messages.Startingwithatheuniformpriorwhatistheposteriorprobabilitythata
messageisspamgiventhatitcontainsthewordenhancement.
A:a)p(enhancement|Spam)=1500/10000=.15,p(enhancement|notSpam)=20/5000=
.004,p(Spam|enhancement)=(.15*.4)/(.15*.5+.004*.5)=.150/.154=.974or97.4%
KnowhowtodoaBayestheoremprobleminvolvingspamfilters(1,2,or3filterwords).
Moreexamplescanbefoundonthehomeworkproblems,whichmightbeworthcopying
ontoyourformulassheet.
16
IDEASFORSTUFFTOCOPYDOWN
Best/worstcasesforalgorithms
Formulas
TableofStirlingnumbersofthesecondkind
Homeworkproblems
Typedupvocab(fromexam2)
WarshallexplainedwellbyLuluTang
17