ebook img

Algorithmic Puzzles PDF

280 Pages·2011·1.162 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Algorithmic Puzzles

Algorithmic Puzzles This page intentionally left blank ALGORITHMIC PUZZLES Anany Levitin and Maria Levitin 3 3 OxfordUniversityPress,Inc.,publishesworksthatfurther OxfordUniversity’sobjectiveofexcellence inresearch,scholarship,andeducation. Oxford NewYork Auckland CapeTown DaresSalaam HongKong Karachi KualaLumpur Madrid Melbourne MexicoCity Nairobi NewDelhi Shanghai Taipei Toronto Withofficesin Argentina Austria Brazil Chile CzechRepublic France Greece Guatemala Hungary Italy Japan Poland Portugal Singapore SouthKorea Switzerland Thailand Turkey Ukraine Vietnam Copyright©2011byOxfordUniversityPress PublishedbyOxfordUniversityPress,Inc. 198MadisonAvenue,NewYork,NewYork10016 www.oup.com OxfordisaregisteredtrademarkofOxfordUniversityPress Allrightsreserved.Nopartofthispublicationmaybereproduced, storedinaretrievalsystem,ortransmitted,inanyformorbyanymeans, electronic,mechanical,photocopying,recording,orotherwise, withoutthepriorpermissionofOxfordUniversityPress. LibraryofCongressCataloging-in-PublicationData Levitin,Anany. Algorithmicpuzzles/AnanyLevitin,MariaLevitin. p.cm. Includesbibliographicalreferencesandindex. ISBN978-0-19-974044-4(pbk.) 1.Mathematicalrecreations. 2.Algorithms. I.Levitin,Maria. II.Title. QA95.L4752011 793.74—dc22 2010052043 9 8 7 6 5 4 3 2 1 PrintedintheUnitedStatesofAmerica onacid-freepaper To Max with love This page intentionally left blank Contents Preface ix Acknowledgments xiii ListofPuzzles xv TutorialPuzzles xv MainSectionPuzzles xvi TheEpigraphPuzzle:Whosaidwhat? xxi 1. Tutorials 3 GeneralStrategiesforAlgorithmDesign 3 AnalysisTechniques 22 2. Puzzles 32 EasierPuzzles(#1to#50) 32 PuzzlesofMediumDifficulty(#51to#110) 45 HarderPuzzles(#111to#150) 60 3. Hints 72 4. Solutions 82 References 241 DesignStrategyandAnalysisIndex 247 IndexofTermsandNames 254 This page intentionally left blank PrefaceinQuestionsand Answers WHAT IS THIS BOOK ABOUT? Thisbookisacollectionofalgorithmicpuzzles—puzzlesthatinvolve,explicitlyor implicitly,clearlydefinedproceduresforsolvingproblems.Itisauniquecollection ofsuchpuzzles.Thebookincludessomeoldclassics,whichhavebecomeapartof mathematicsandcomputersciencefolklore.Italsocontainsnewerexamples,some ofwhichhavebeenaskedduringjobinterviewsatmajorcompanies. Thebookhastwomaingoals: • Toentertainawiderangeofreadersinterestedinpuzzles • Topromotedevelopmentofhigh-levelalgorithmicthinking(withno computerprogramming),supportedbyacarefullydevelopedlistof generalalgorithmdesignstrategiesandanalysistechniques Although algorithms do constitute the cornerstone of computer science and no sensible computer programming is possible without them, it is a common misconceptiontoequatethetwo.Somealgorithmicpuzzlespredatecomputersby morethanathousandyears.Itistrue,however,thattheproliferationofcomputers has made algorithmic problem solving important in many areas of modern life, fromhardandsoftsciencestoartandentertainment.Solvingalgorithmicpuzzlesis themostproductiveanddefinitelymostenjoyablewaytodevelopandstrengthen one’salgorithmicthinkingskills. WHOM IS THIS BOOK FOR? There are three large categories of readers who should be interested in this book: • Puzzlelovers • Peopleinterestedindevelopingalgorithmicthinking,includingteachers andstudents • Peoplepreparingforinterviewswithcompaniesgivingpuzzlesaswellas peopleconductingsuchinterviews All we have to say to puzzle lovers is to reassure them that they could enjoy this collection as they would a collection not dedicated to any particular theme or type of puzzle. They will encounter a few all-time favorites, but, hopefully, will also find a number of little-known puzzle gems. No computing background ix

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.