Homework#1solutionscontinuedQuestion5.CLRS4-6.a. Ifmorethann/2chipsarebad,thenasubsetofthebadchipscanactlikegoodchips.Thenumberofblackchipsthatdothiscanbethesameasthenumberofgoodchips(whichislessthann/2),makingitimpossibletodiscernbetweentheseblackchipsandthegoodchips(bothsetsofthesamesize).Thismeansthatitispossibleforasubsetofthebadchips(thenumberofblackchipsinthissubsetisequaltothenumberofgoodchips)toreportaccuratelywhethertheotherchipisgoodorbad.Assumingthatthesebadchipsalwaysdothis,itwouldbeimpossibletotellthedifferencebetweenthegoodchipsandthesebadchips.Thatis,theredoesnotexistamethodbywhichtodeterminewhicharethegoodchips.Hereisanillustrationbelowthatillustratesthispoint:b. TheanswertothisquestionliesinthetwoquestionsthatareaskedbyProfessorKahngonthediscussionboard.Thefirstquestionis1)ifyouputtwochipsonthetester,andtheresultsaysthatoneofthemisbad,whathappensifyou“throwbothofthechipsaway”?Inthiscase,ifyouthrowbothofthechipsaway,thensinceyouknowthatatleastoneofthechipsisbad,thenyouarestillleftwithasetofchipsthathaveamajorityofgoodchips.Thesecondquestionis2)ifyouhaveKpairsofchips,eachofwhichisan“identicalpair”(i.e.,X-X,whereXcanbeeitherGoodorBad–youcan’ttell)–and,the2KchipstogetherhaveamajorityofGoodchips–isthereanywaythatyoucancomeupwithasmallersetofchipswhichstillhaveamajorityofGoodchips?Theanswertothisquestionisyes.Youcaneasilydothisbythrowingawayoneofthechipsfromeachpair.Then,youstillhaveamajorityofgoodchips.Therefore,combinethetwoquestions,sotospeak.Ifyouaregivennchips,beginapairwisecomparison.Ifoneormoreislabeledasbad,throwthembothout.Iftheyarebothlabeledasgood,storetheminapile,butattheendofthepairwisecomparisonsofallthechips,throwoutonechipfromeachpairwhichsaidthatthechipswerebothgood.Ifyoudothis,thenyouareguaranteedtohaveasetofBadchipsgoodchipssubsetofbadchipsactinglikegoodchipschipswithamajorityofgoodchips,wherethesizeofthesetishalfthesizeoftheoriginalset.Afterfinishingthisalgorithmyouwillbeleftwithonechip,whichwillbegood.c.
View Full Document