Applied Discrete Structures Applied Discrete Structures Al Doerr University of Massachusetts Lowell Ken Levasseur University of Massachusetts Lowell September, 2016 © 2016 Al Doerr, Ken Levasseur Applied Discrete Structures by Alan Doerr and Kenneth Levasseur is licensed un- deraCreativeCommonsAttribution-NonCommercial-ShareAlike3.0UnitedStates License. You are free to Share: copy and redistribute the material in any medium orformat; Adapt: remix,transform,andbuilduponthematerial. Youmaynotuse the material for commercial purposes. The licensor cannot revoke these freedoms as long as you follow the license terms. To our families Donna, Christopher, Melissa, and Patrick Doerr Karen, Joseph, Kathryn, and Matthew Levasseur Acknowledgements List 0.0.1 (Instructor Contributions). We would like to acknowledge the following instructors for their helpful comments and suggestions. • Tibor Beke, UMass Lowell • Sitansu Mittra, UMass Lowell • Alex DeCourcy, UMass Lowell • Ravi Montenegro, UMass Lowell • Vince DiChiacchio • Tony Penta, UMass Lowell • Dan Klain, UMass Lowell • Jim Propp, UMass Lowell I’d like to particularly single out Jim Propp for his close scrutiny, along with that of his students, who are listed below. List 0.0.2 (Student Contributions). Many students have provided feedback and pointed out typos in several editions of this book. They are listed below. Students with no affiliation listed are from UMass Lowell. • Anju Balaji • Michael Ingemi • Paola Pevzner • Chris Berns • William Jozefczyk • Samantha Poirier • Raymond Berger, • Leant Seu Kim • Ian Roberts Eckerd College • John Kuczynski • Chita Sano • Sam Bouchard • Kendra Lansing • Mason Sirois • Rebecca Campbell • Ariel Leva • Sam Chambers • Doug Salvati • Andrew Magee • Alex DeCourcy • Anh Vo • Ryan Delosh • Nick McArdle • Several students at Luzurne County • Anthony Gaeta • Mike Morley Community College • Holly Goodreau • Hung Nguyen (PA) I would like to thank Rob Beezer, David Farmer and other participants on the mathbook-xml-support group for their guidance and work on MathBook XML. Thanks to the Pedagogy Subcommittee of the UMass Lowell Transformational Ed- ucation Committee for their financial assistance in helping getting this project started. vii viii Preface This version of Applied Discrete Structures is being developed using Mathbook XML, A lightweight XML application for authors of scientific articles, textbooks and monographs initiated by Rob Beezer, U. of Puget Sound. We embarked on this open-source project in 2010. The choice of Mathematica for "source code" was based on the speed with which we could do the conversion. However,theformatwasnotideal,withnoviablewebversionavailable. Theproject hasbeen well-received inspiteof theseissues. Validation throughthelistingofthis projectontheAmericanInstituteofMathematicshasbeenveryhelpful. Whenthe MBX project was launched, it was the natural next step. The features of MBX make it far more readable than our first versions, with web, pdf and print copies being far more readable. Twenty-one years after the publication of the 2nd edition of Applied Discrete Structures for Computer Science, in 1989 the publishing and computing landscape had both changed dramatically. We signed a contract for the second edition with Science Research Associates in 1988 but by the time the book was ready to print, SRAhadbeensoldtoMacMillan. Soonafter,therightshadbeenpassedontoPear- sonEducation,Inc. In2010,thelong-termfutureofprintedtextbooksisuncertain. In the meantime, textbook prices (both printed and e-books) have increased and a growingopensourcetextbookmarketmovementhasstarted. Oneofourobjectives inrevisitingthistextistomakeitavailabletoourstudentsinanaffordableformat. In its original form, the text was peer-reviewed and was adopted for use at sev- eral universities throughout the country. For this reason, we see Applied Discrete Structures as not only an inexpensive alternative, but a high quality alternative. As indicated above the computing landscape is very different from the 1980’s andaccountsforthemostsignificantchangesinthetext. Oneofthemostcommon programming languages of the 1980’s, Pascal; and we used it to illustrate many of the concepts in the text. Although it isn’t totally dead, Pascal is far from the mainstream of computing in the 21st century. In 1989, Mathematica had been out for less than a year — now a major force in scientific computing. The open source software movement also started in the 1980’s and in 2005, the first version of Sage, an open-source alternative to Mathematica was first released. In Applied Discrete Structures we have replaced "Pascal Notes" with "Mathematica Notes" and "Sage Notes." Finally, 1989 was the year that World Wide Web was invented by Tim Berners-Lee. There wasn’t a single www in the 2nd edition. Sage (sagemath.org) is a free, open source, software system for advanced math- ematics. Sage can be used either on your own computer, a local server, or on SageMathCloud (https://cloud.sagemath.com). Ken Levasseur Lowell MA ix x