ebook img

Discrete Algorithmic Mathematics, Third Edition PDF

779 Pages·2005·4.181 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 Discrete Algorithmic Mathematics, Third Edition

Discrete Algorithmic Mathematics Third Edition Stephen B Maurer Swarthmore College Anthony Ralston State University of New York at Buffalo A K Peters, Ltd. Wellesley, Massachusetts CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2005 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Version Date: 20130204 International Standard Book Number-13: 978-1-4398-6375-6 (eBook - PDF) Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com Contents List of Algorithms inside front cover Instructor’s Preface ix Student’s Preface xiv Chapter Summaries xvii Pathways Through the Book xx Problem DifficultyRating xxii Symbols, Notation,Abbreviations and Conventions xxiii PROLOGUE What Is Discrete Algorithmic Mathematics? 1 CHAPTER 0 Mathematical Preliminaries 9 0.1 Sets, Relations, and Functions 9 0.2 Some Important Functions 20 0.3 Growth Rates and Order Notation 30 0.4 Summationand Product Notation 40 0.5 Matrix Algebra 50 0.6 The Language and Methods of Reasoning 56 Supplementary Problems 69 CHAPTER 1 Algorithms 73 1.1 Some Examples of Algorithms 73 1.2 Aspects of AL 88 1.3 Recursive Algorithms 94 1.4 Algorithmic Language: Procedures and Functions 105 1.5 The Analysis of Algorithms 117 Supplementary Problems 131 CHAPTER 2 Mathematical Induction 135 2.1 Introduction 135 2.2 First Examples 137 2.3 Strong Induction and Other Variants 151 2.4 Induction and Recursive Algorithms 158 2.5 Induction and Iterative Algorithms 168 2.6 How to Conjecture What to Prove 180 2.7 Inductive Definitions 194 2.8 Faulty Inductions 201 Supplementary Problems 210 CHAPTER 3 Graphs and Trees 217 3.1 Examples and Terminology 217 3.2 Paths, Cycles and the Adjacency Matrix 236 3.3 Eulerian and HamiltonianPaths and Cycles 250 3.4 Shortest Paths 266 3.5 Breadth First Search and Depth First Search 278 3.6 ColoringProblems 285 3.7 Trees 296 Supplementary Problems 311 CHAPTER 4 Fundamental Counting Methods 321 4.1 Introduction 321 4.2 First Examples: The Sum and Product Rules 322 4.3 Subtler Examples and Further Rules 329 4.4 Permutations and Combinations 341 4.5 CombinatorialIdentities and CombinatorialArguments 348 4.6 The BinomialTheorem 355 4.7 Four Common Problems with Balls and Urns 365 4.8 Generating Functions 375 4.9 CombinatorialAlgorithms 385 4.10 Algorithmic Pigeonholes 399 Supplementary Problems 406 CHAPTER 5 Difference Equations 411 5.1 Introduction 411 5.2 Modeling with Difference Equations 413 5.3 Getting Information from Difference Equations 426 5.4 Terminologyand a Fundamental Theorem 433 5.5 Constant Coefficient Homogeneous Linear Difference Equations 439 5.6 Qualitative Analysis 451 5.7 Nonhomogeneous Difference Equations 457 5.8 Applications to Algorithms 462 5.9 Variable Coefficients, Sums, and Recent Advances in Computer Algebra 479 5.10 Nonlinear Difference Equations 484 5.11 Finite Differences 495 Supplementary Problems 508 CHAPTER 6 Probability 513 6.1 Introduction 513 6.2 ProbabilitySpace 517 6.3 ConditionalProbability,Independence, and Bayes’ Theorem 527 6.4 Random Variables and Distributions 539 6.5 Expected Value 557 6.6 Variance 569 6.7 Statistical Estimation 577 6.8 Applications to Algorithms: Proofs of Prior Claims 586 6.9 Recursive Methods in Probability 595 Supplementary Problems 606 CHAPTER 7 An Introductionto Mathematical Logic 611 7.1 Introduction and Terminology 611 7.2 The Propositional Calculus 616 7.3 Validityand Tautology 630 7.4 Algorithm Verification 637 7.5 Boolean Algebra 643 7.6 The Predicate Calculus 663 7.7 Algorithm Verification Using the Predicate Calculus 676 7.8 Theorems and Proofs 682 Supplementary Problems 689 EPILOGUE Coming Full Circle with Biology and Minimax Theorems 691 E.1 DNA Matching 691 E.2 Algorithmic Mathematics and Minimax Theorems 707 Final Problems 717 References 723 Appendix: Limits 729 Hints and Answers 733 Index 761 List of Algorithms Thistablelistsallthenumberedalgorithmsinthebook. Allalgorithmsdisplayedin boxesinthetextarenumbered, aswellasthemoreimportantalgorithmsdisplayed in boxes in the problems. In addition, there are numerous algorithm fragments both in the text and in the problems. The fragments and unnumbered algorithms illustrate some point and are generally not important algorithmsin themselves. Number Name OutputorPurpose Page 1.1 PowerA Computesintegerpowersofanumber 74 1.2 PowerB Speed-upof1.1forsomepowers 75 1.3 PowerC Speed-upof1.1 75 1.4 PrimeNum FirstK primenumbers 77 1.5 FiberNet Minimumcostlinksinanetwork 80 1.6 Euclid Greatestcommondivisor(gcd)oftwointegers 84,123,170 1.7 Euclid1 Possiblyfastervariantof1.6 87 1.8 Euclid-RecFunc Recursivefunctionversionof1.6 96,163 1.9 Euclid-RecPro Recursiveprocedureversionof1.6 97,165 1.10 Hanoi TowersofHanoi 101 1.11 StringProc Processastringofcharacters 109 1.12 MaxNumber Maximumofnnumbers 119,587 1.13 SeqSearch Sequentialsearchofalist 125 1.14 BinSearch Binarysearchofalist 127,172 1.15 Euclid2 Possiblyfastervariantof1.6 132 2.1 Hanoi Slightrewriteof1.10 160 2.2 TOH VariantrecursiveprocedureforHanoi 166 2.3 EuclidRound-Func Possiblyfastervariantof1.8 167 2.4 EuclidRound-Pro Possiblyfastervariantof1.9 167 2.5 Euclid-RoundUp Possiblyfastervariantof1.6 167 2.6 Iterative-TOH Non-recursiveTowersofHanoi 179 2.7 Sum-Search Findifonenumberisthesumofsomeothers 213 2.8 EuclidZ Versionof1.6thatalsoworksfornegativeintegers 214 3.1 BuildTree Binarytreeofalistofwords 223 3.2 Warshall Pathmatrixofagraph 244 3.3 Pathgrow Growsapathinagraph 255 3.4 Ecycle AnEuleriancycleinagraph 256 Number Name OutputorPurpose Page 3.5 HamPath AHamiltonianpathinacompletegraph 261 3.6 Dijkstra Shortestpathinaweightedgraph 272 3.7 BreadthFirstSearch Breadthfirstsearchofaconnectedgraph 279 3.8 PathLength Lengthsofallpathsfromagivenvertex 281 3.9 DepthFirstSearch Depthfirstsearchofaconnectedgraph 282 3.10 Bipartite Determineifagraphis2-colorable 288 3.11 K-Colorable Apropercoloringofagraph 291 3.13 Color-by-Vertices Variantof3.11 294 3.13 One-Color-at-a-Time Differentapproachtocoloringagraph 294 3.14 SpanTree Spanningtreeofagraph 297 3.15 MinSpanTree Minimumweightspanningtreeofagraph 299 3.16 BinaryTreeTraversal Threewaysoftraversingabinarytree 306 3.17 Ford Shortestpathinaweightedgraph 314 4.1 PermValue ThepermutationnumberP(n,r) 343 4.2 PermValue2 ThepermutationnumberP(n,r) 347 4.3 Permute-1 Randompermutationof[n] 388,590 4.4 Permute-2 Randompermutationof[n] 390,592 4.5 Permute-3 Randompermutationof[n] 391 4.6 AllPerm Allpermutationsof[n] 394 4.7 Monotonic Longestmonotonicsubsequence 402 5.1 Straightforward Polynomialevaluation 463 5.2 Horner Fasterpolynomialevaluation 464 5.3 FibA Fibonaccinumbers 466 5.4 FibB Fibonaccinumbersbyrecursion 466 5.5 PowerPoly Polynomialevaluation 475 6.1 BigNext Twolargestofnnumbers 593 7.1 Mult Integermultiplication 615 7.2 Insertion Insertionsortofalist 678 E.1 StringAlign-Rec OptimalalignmentofDNA strings 697 E.2 StringAlign IterativeOptimalAlignment 699 E.3 StringAlign2 VariantofE.2 704 E.4 ProjectSched Minimumcompletiontime 709 Instructor’s Preface Theoriginalversionofthisbook,publishedin1991,wasintended tomakeconcrete our idea that discrete mathematics could and should be a year course in under- graduate mathematics and be a coequal of calculus in the first two years of the undergraduate curriculum. However,nowasthen, fewstudents takeafullyearofdiscrete mathduringthe first two undergraduate years. Therefore, this new edition of our book focuses on a one-semester discrete mathematics course. Almostno one disputes anylonger that discrete math isimportant and that it hasaplaceinawell-roundedmathematicsorcomputerscience program. Moreover, more and more is showing up in the school curriculum. Also, physical and social scientists urge their students to learnsome. Thus, manystudents froma varietyof disciplines know about discrete math and now study it somewhere, or should. Althoughthis3rdeditionofDAM(asweliketocallit,orinthiscaseDAM3)is intended for a one-semester course, we think it contains enough material for about one-and-a-halfsemesters. It’sourideaofwhat’smostimportanttodo,forstudents of various disciplines, given only a semester, with various options about what to emphasize. Most instructors willwantto either skip somesections ofeach chapter, or skip some chapters. See Pathways Through the Book later in the front matter. Algorithms, Paradigms, and Discrete Mathematics We think that discrete mathematics needs a central theme. In fact, our book has both a central object algorithms and two central methods the inductive and recursive paradigms. We now say a bit about these. There have always been algorithms in mathematics. Furthermore, with the great importance today of algorithms, it is now recognized that humans need a precise waytocommunicatetoeachother (notjusttomachines)aboutalgorithms. Hence the increased use of “algorithmic language” in discrete (and other) mathe- matics books, including this book. (We don’t call it “pseudocode” because from the point of view of communication between humans there is nothing “pseudo” about it.) Our algorithmic notation is more formal than in most discrete mathematics books, but less formalthan that in books which use an actual computer language. Wethinkitisimportantthatstudents learnearlytotreatalgorithmsasmathemat- ical objects, with appropriate precision. Nevertheless, our language is sufficiently simple, and the meaning of its structures sufficiently transparent, that even stu- dents with little or no computer experience should be able to understand it, read it, and write simple algorithms with it. In particular, a programming course is not a prerequisite for this book, although some prior experience with algorithmic constructs is helpful. Manymathematiciansstillregardalgorithmsasafterthoughts firstyouprove that something exists and later, as a lesser activity,you find some way to compute thething. Inourphilosophy,algorithmsaremorecentralthanthat. Algorithmscan be used to prove that objects exist and simultaneously provide a way to construct them thus providing the elegance of a stone that kills two birds. This idea of “proof by algorithm” shows up repeatedly in our book. Algorithms are also an object of mathematical study as well as an engine for proofs. We devote much attention to the analysis of algorithms (how long they take to run) and to proofs of correctness. Our attitude towards algorithms is summarized by our title. It is not “Dis- crete Mathematics”; it is not even “Discrete Mathematics with Algorithms”; it is “Discrete Algorithmic Mathematics”. “Algorithmic” is an essential modifier of “Mathematics”. Of course, we do not mean “algorithmic” in the sense of rote ap- plication of rules, but rather in the sense of algorithmics,which means thinking in terms of algorithms and their mathematicalstudy. Buthowdoyoudeviseanalgorithmwhichsolvestheproblemathand,andhow doyouconvinceyourselfyouareright? Thisiswhere ourcentralmethods comein. The inductive paradigm is the method of building up cases, looking for patterns, and thus obtaining a (usually) iterative algorithm. The recursive paradigm is the method of supposing you already know how to handle previous cases, finding a connection to the current case, and thus obtaininga (usually) recursive algorithm. Weemphasize repeatedly howmuch mileageone can get withthese elaborationsof the simple ideas “build from the previous case” and “reduce to the previous case”. What Hasn’t Changed from Earlier Editions Ourbookremainsnotableamongdiscrete mathematicsbooksinanumberofways. It’suseofalgorithmicsasacentraltheme. Whilethecoverageofalgorithmics inother discrete books hasincreased since ourbookoriginallyappeared, this theme remains more central in our book than in any other. Put another way, DAM has a point of view. We believe that algorithms are a key mathematical concept, and issues about algorithmic implementa- tion should not be far away when thinking about any mathematical idea. In addition, on several occasions (for instance, the Euler Graph Theorem or the monotone subsequence corollary of the Pigeonhole Principle), we il- lustrate both existential and algorithmic approaches to both the statement of the theorem and its proof. We favor the algorithmic approach, but we acknowledge the value of both. DAMprovidesabroad course,withdiscussionandexamplesondiscretetopics fromawidevarietyofdisciplines,notjustmathematicsandcomputerscience. (See Chapter Summaries later in the front matter for a clearer idea of what wemeanbythis.) WethinkthatDAMwilltherefore appealtostudents with a wide variety of interests. DAM has worked especially well with better prepared students and is more sophisticated than most discrete texts. It’s not that DAM is a theoretical book, concerned only with proofs and intended for juniors and seniors. On thecontrary,forthemostpartourpresentation isfairlyinformalandconcen- trates on problem solving and modeling using the standard techniques and concepts ofthe subject. (Chapter 2,Induction, isan exception.) Rather, the sophistication comes from how we talk about the methods (we show how we as a mathematician and a computer scientist think about them) and from the problem sets. Those students who actually read their math books will gain a lot. And while there are many routine problems, there are plenty of nonroutine ones too, often with lengthy discussions about why they are interesting. (See the discussion later of our ranking system for problems.) Inanyevent,DAMshouldhelpstudents developmathematicalmaturity. They will gainsome idea of what a good mathematicalargument is and will take first steps toward learning how to devise and present such arguments themselves. What Has Changed Chapters 8(linearalgebra)and9(bridgetocontinuousmaththroughinfinite processes) have been deleted. Some material from Chapter 9 (generating functions, order of growth, finite differences) has been retained by movingit forward. Several parts of Chapter 0 have been shortened, for instance, the discussions of sets, relations, and functions. Chapter 1 has also been shortened, by reducing the number of examples. Because discussion of Ord and Big-Oh notation has been moved forward (to Chapter 0), we include more explicit discussion of the order of algorithms throughout the book. The syntax of our Algorithm Language has been changed modestly. Fol- lowing a reader suggestion, we have made inputs and outputs to procedures explicit. This provides added clarity and makes it easier to explain the close tie between recursion in algorithms and proof by induction. Chapter 5 (difference equations) contains new sections on nonlinear recur- rences (chaos) and finite differences. The old Epilogue on sorting has been replaced by a new Epilogue that high- lights computational biology,an important current topic. Many problems have been added or revised. Many small changes to improve clarity have been made on virtually every page. ComputerAlgebraSystems. CASshavebeenmentionedinDAMsinceDAM1, but when we first started writing,it was not clear whether such automationwould revolutionize mathematics and its teaching or be a dud. It has worked out in- between. A CAS, like a pencil, is a wonderful tool, and it is important to know

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.