ebook img

Algorithm Design PDF

864 Pages·2005·4.981 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 Algorithm Design

This page intentionally left blank AcquisitionsEditor: MattGoldstein ProjectEditor: MaiteSuarez-Rivas ProductionSupervisor: MarilynLloyd MarketingManager: MichelleBrown MarketingCoordinator: JakeZavracky ProjectManagement: WindfallSoftware Composition: WindfallSoftware,usingZzTEX Copyeditor: CarolLeyba TechnicalIllustration: DartmouthPublishing Proofreader: JenniferMcClain Indexer: TedLaux CoverDesign: JoyceCosentinoWells CoverPhoto: ©2005TimLaman/NationalGeographic.Apairofweaverbirdswork togetherontheirnestinAfrica. PrepressandManufacturing: CarolineFell Printer: CourierWestford AccessthelatestinformationaboutAddison-WesleytitlesfromourWorldWideWeb site:http://www.aw-bc.com/computing Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printedininitialcapsorallcaps. The programs and applications presented in this book have been included for their instructionalvalue.Theyhavebeentestedwithcare, butarenotguaranteedforany particularpurpose.Thepublisherdoesnotofferanywarrantiesorrepresentations,nor doesitacceptanyliabilitieswithrespecttotheprogramsorapplications. LibraryofCongressCataloging-in-PublicationData Kleinberg,Jon. Algorithmdesign/JonKleinberg,E´vaTardos.—1sted. p. cm. Includesbibliographicalreferencesandindex. ISBN0-321-29535-8(alk.paper) 1.Computeralgorithms. 2.Datastructures(Computerscience) I.Tardos,E´va. II.Title. QA76.9.A43K542005 005.1—dc22 2005000401 Copyright©2006byPearsonEducation,Inc. For information on obtaining permission for use of material in this work, please submitawrittenrequesttoPearsonEducation,Inc.,RightsandContractDepartment, 75ArlingtonStreet,Suite300,Boston,MA02116orfaxyourrequestto(617)848-7047. All rights reserved. No part of this publication may be reproduced, stored in a retrievalsystem,ortransmitted,inanyformorbyanymeans,electronic,mechanical, photocopying,recording,oranytohermediaembodimentsnowknownorhereafterto becomeknown,withoutthepriorwrittenpermissionofthepublisher.Printedinthe UnitedStatesofAmerica. ISBN0-321-29535-8 1 2 3 4 5 6 7 8 9 10-CRW-08 07 06 05 About the Authors Jon Kleinberg is a professor of Computer Science at CornellUniversity.HereceivedhisPh.D.fromM.I.T. in1996.HeistherecipientofanNSFCareerAward, anONRYoungInvestigatorAward,anIBMOutstand- ing Innovation Award, the National Academy of Sci- encesAwardforInitiativesinResearch,researchfel- lowships from the Packard and Sloan Foundations, and teaching awards from the Cornell Engineering CollegeandComputerScienceDepartment. Kleinberg’sresearchiscenteredaroundalgorithms,particularlythosecon- cernedwiththestructureofnetworksandinformation,andwithapplications to information science, optimization, data mining, and computational biol- ogy.Hisworkonnetworkanalysisusinghubsandauthoritieshelpedformthe foundationforthecurrentgenerationofInternetsearchengines. E´vaTardosisaprofessorofComputerScienceatCor- nell University. She received her Ph.D. from Eo¨tvo¨s University in Budapest, Hungary in 1984. She is a member of the American Academy of Arts and Sci- ences,andanACMFellow;sheistherecipientofan NSFPresidentialYoungInvestigatorAward,theFulk- erson Prize, research fellowships from the Guggen- heim, Packard, and Sloan Foundations, and teach- ingawardsfromtheCornellEngineeringCollegeand ComputerScienceDepartment. Tardos’s research interests are focused on the design and analysis of algorithms for problems on graphs or networks. She is most known for her work on network-flow algorithms and approximation algorithms for network problems. Her recent work focuses on algorithmic game theory, an emerging areaconcernedwithdesigningsystemsandalgorithmsforselfishusers. This page intentionally left blank Contents About the Authors v Preface xiii 1 Introduction: Some Representative Problems 1 1.1 AFirstProblem:StableMatching 1 1.2 FiveRepresentativeProblems 12 SolvedExercises 19 Exercises 22 NotesandFurtherReading 28 2 Basics of Algorithm Analysis 29 2.1 ComputationalTractability 29 2.2 AsymptoticOrderofGrowth 35 2.3 Implementing the Stable Matching Algorithm Using Lists and Arrays 42 2.4 ASurveyofCommonRunningTimes 47 2.5 AMoreComplexDataStructure:PriorityQueues 57 SolvedExercises 65 Exercises 67 NotesandFurtherReading 70 3 Graphs 73 3.1 BasicDefinitionsandApplications 73 3.2 GraphConnectivityandGraphTraversal 78 3.3 ImplementingGraphTraversalUsingQueuesandStacks 87 3.4 TestingBipartiteness:AnApplicationofBreadth-FirstSearch 94 3.5 ConnectivityinDirectedGraphs 97 viii Contents 3.6 DirectedAcyclicGraphsandTopologicalOrdering 99 SolvedExercises 104 Exercises 107 NotesandFurtherReading 112 4 Greedy Algorithms 115 4.1 IntervalScheduling:TheGreedyAlgorithmStaysAhead 116 4.2 SchedulingtoMinimizeLateness:AnExchangeArgument 125 4.3 OptimalCaching:AMoreComplexExchangeArgument 131 4.4 ShortestPathsinaGraph 137 4.5 TheMinimumSpanningTreeProblem 142 4.6 Implementing Kruskal’s Algorithm: The Union-Find Data Structure 151 4.7 Clustering 157 4.8 HuffmanCodesandDataCompression 161 ∗ 4.9 Minimum-Cost Arborescences: A Multi-Phase Greedy Algorithm 177 SolvedExercises 183 Exercises 188 NotesandFurtherReading 205 5 Divide and Conquer 209 5.1 AFirstRecurrence:TheMergesortAlgorithm 210 5.2 FurtherRecurrenceRelations 214 5.3 CountingInversions 221 5.4 FindingtheClosestPairofPoints 225 5.5 IntegerMultiplication 231 5.6 ConvolutionsandtheFastFourierTransform 234 SolvedExercises 242 Exercises 246 NotesandFurtherReading 249 6 Dynamic Programming 251 6.1 WeightedIntervalScheduling:ARecursiveProcedure 252 6.2 Principles of Dynamic Programming: Memoization or Iteration overSubproblems 258 6.3 SegmentedLeastSquares:Multi-wayChoices 261 ∗Thestarindicatesanoptionalsection.(SeethePrefaceformoreinformationabouttherelationships amongthechaptersandsections.)

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.