Table Of ContentKenneth H. Rosen
Discrete
Mathematics
and Its
Applications
Eighth Edition
Discrete
Mathematics
and Its
Applications
Eighth Edition
Kenneth H. Rosen
formerlyAT&TLaboratories
DISCRETEMATHEMATICSANDITSAPPLICATIONS,EIGHTHEDITION
PublishedbyMcGraw-HillEducation,2PennPlaza,NewYork,NY10121.Copyright(cid:2)c 2019byMcGraw-HillEducation.Allrightsreserved.Printed
intheUnitedStatesofAmerica.Previouseditions(cid:2)c 2012,2007,and2003.Nopartofthispublicationmaybereproducedordistributedinanyformor
byanymeans,orstoredinadatabaseorretrievalsystem,withoutthepriorwrittenconsentofMcGraw-HillEducation,including,butnotlimitedto,inany
networkorotherelectronicstorageortransmission,orbroadcastfordistancelearning.
Someancillaries,includingelectronicandprintcomponents,maynotbeavailabletocustomersoutsidetheUnitedStates.
Thisbookisprintedonacid-freepaper.
123456789LWI21201918
ISBN 978-1-259-67651-2
MHID 1-259-67651-X
ProductDeveloper:NoraDevlin
MarketingManager:AlisonFrederick
ContentProjectManager:PeggySelle
Buyer:SandyLudovissy
Design:EgzonShaqiri
ContentLicensingSpecialist:LorraineBuczek
CoverImage:(cid:2)cKarlDehnam/AlamyStockPhoto
Compositor:Aptara,Inc.
Allcreditsappearingonpageorattheendofthebookareconsideredtobeanextensionofthecopyrightpage.
LibraryofCongressCataloging-in-PublicationData
Names:Rosen,KennethH.,author.
Title:Discretemathematicsanditsapplications/KennethH.Rosen,Monmouth
University(andformerlyAT&TLaboratories).
Description:Eighthedition.|NewYork,NY:McGraw-Hill,[2019]|Includes
bibliographicalreferencesandindex.
Identifiers:LCCN2018008740|ISBN9781259676512(alk.paper)|
ISBN125967651X(alk.paper)
Subjects:LCSH:Mathematics.|Computerscience–Mathematics.
Classification:LCCQA39.3.R672019|DDC511–dc23LCrecordavailableat
https://lccn.loc.gov/2018008740
TheInternetaddresseslistedinthetextwereaccurateatthetimeofpublication.Theinclusionofawebsitedoesnotindicateanendorsementbythe
authorsorMcGraw-HillEducation,andMcGraw-HillEducationdoesnotguaranteetheaccuracyoftheinformationpresentedatthesesites.
mheducation.com/highered
Contents
AbouttheAuthorvi
Prefacevii
OnlineResourcesxvi
TotheStudentxix
1 TheFoundations:LogicandProofs....................................1
1.1 PropositionalLogic............................................................1
1.2 ApplicationsofPropositionalLogic.............................................17
1.3 PropositionalEquivalences .................................................... 26
1.4 PredicatesandQuantifiers.....................................................40
1.5 NestedQuantifiers............................................................60
1.6 RulesofInference.............................................................73
1.7 IntroductiontoProofs.........................................................84
1.8 ProofMethodsandStrategy....................................................96
End-of-ChapterMaterial.....................................................115
2 BasicStructures:Sets,Functions,Sequences,Sums,
andMatrices.......................................................121
2.1 Sets........................................................................121
2.2 SetOperations...............................................................133
2.3 Functions...................................................................147
2.4 SequencesandSummations...................................................165
2.5 CardinalityofSets...........................................................179
2.6 Matrices....................................................................188
End-of-ChapterMaterial.....................................................195
3 Algorithms.........................................................201
3.1 Algorithms..................................................................201
3.2 TheGrowthofFunctions.....................................................216
3.3 ComplexityofAlgorithms....................................................231
End-of-ChapterMaterial.....................................................244
4 NumberTheoryandCryptography..................................251
4.1 DivisibilityandModularArithmetic...........................................251
4.2 IntegerRepresentationsandAlgorithms........................................260
4.3 PrimesandGreatestCommonDivisors ........................................ 271
4.4 SolvingCongruences.........................................................290
4.5 ApplicationsofCongruences ................................................. 303
4.6 Cryptography ............................................................... 310
End-of-ChapterMaterial.....................................................324
iii
iv Contents
5 InductionandRecursion............................................331
5.1 MathematicalInduction......................................................331
5.2 StrongInductionandWell-Ordering...........................................354
5.3 RecursiveDefinitionsandStructuralInduction..................................365
5.4 RecursiveAlgorithms........................................................381
5.5 ProgramCorrectness.........................................................393
End-of-ChapterMaterial.....................................................398
6 Counting...........................................................405
6.1 TheBasicsofCounting.......................................................405
6.2 ThePigeonholePrinciple.....................................................420
6.3 PermutationsandCombinations...............................................428
6.4 BinomialCoefficientsandIdentities...........................................437
6.5 GeneralizedPermutationsandCombinations...................................445
6.6 GeneratingPermutationsandCombinations....................................457
End-of-ChapterMaterial.....................................................461
7 DiscreteProbability.................................................469
7.1 AnIntroductiontoDiscreteProbability ........................................469
7.2 ProbabilityTheory...........................................................477
7.3 Bayes’Theorem.............................................................494
7.4 ExpectedValueandVariance.................................................503
End-of-ChapterMaterial.....................................................520
8 AdvancedCountingTechniques ..................................... 527
8.1 ApplicationsofRecurrenceRelations..........................................527
8.2 SolvingLinearRecurrenceRelations .......................................... 540
8.3 Divide-and-ConquerAlgorithmsandRecurrenceRelations......................553
8.4 GeneratingFunctions ........................................................ 563
8.5 Inclusion–Exclusion ......................................................... 579
8.6 ApplicationsofInclusion–Exclusion...........................................585
End-of-ChapterMaterial.....................................................592
9 Relations...........................................................599
9.1 RelationsandTheirProperties................................................599
9.2 n-aryRelationsandTheirApplications.........................................611
9.3 RepresentingRelations.......................................................621
9.4 ClosuresofRelations.........................................................628
9.5 EquivalenceRelations........................................................638
9.6 PartialOrderings ............................................................ 650
End-of-ChapterMaterial.....................................................665
Contents v
10 Graphs.............................................................673
10.1 GraphsandGraphModels....................................................673
10.2 GraphTerminologyandSpecialTypesofGraphs...............................685
10.3 RepresentingGraphsandGraphIsomorphism..................................703
10.4 Connectivity................................................................714
10.5 EulerandHamiltonPaths.....................................................728
10.6 Shortest-PathProblems.......................................................743
10.7 PlanarGraphs...............................................................753
10.8 GraphColoring..............................................................762
End-of-ChapterMaterial.....................................................771
11 Trees...............................................................781
11.1 IntroductiontoTrees.........................................................781
11.2 ApplicationsofTrees ........................................................ 793
11.3 TreeTraversal...............................................................808
11.4 SpanningTrees..............................................................821
11.5 MinimumSpanningTrees....................................................835
End-of-ChapterMaterial.....................................................841
12 BooleanAlgebra....................................................847
12.1 BooleanFunctions...........................................................847
12.2 RepresentingBooleanFunctions .............................................. 855
12.3 LogicGates.................................................................858
12.4 MinimizationofCircuits ..................................................... 864
End-of-ChapterMaterial.....................................................879
13 ModelingComputation ............................................. 885
13.1 LanguagesandGrammars....................................................885
13.2 Finite-StateMachineswithOutput.............................................897
13.3 Finite-StateMachineswithNoOutput.........................................904
13.4 LanguageRecognition ....................................................... 917
13.5 TuringMachines.............................................................927
End-of-ChapterMaterial.....................................................938
Appendices.........................................................A-1
1 AxiomsfortheRealNumbersandthePositiveIntegers..........................A-1
2 ExponentialandLogarithmicFunctions........................................A-7
3 Pseudocode................................................................A-11
SuggestedReadingsB-1
AnswerstoOdd-NumberedExercisesS-1
IndexofBiographiesI-1
IndexI-2
About the Author
K
enneth H. Rosen received his B.S. in Mathematics from the University of Michigan,
Ann Arbor (1972), and his Ph.D. in Mathematics from M.I.T. (1976), where he wrote
histhesisinnumbertheoryunderthedirectionofHaroldStark.BeforejoiningBellLaboratories
in 1982, he held positions at the University of Colorado, Boulder; The Ohio State University,
Columbus;andtheUniversityofMaine,Orono,wherehewasanassociateprofessorofmath-
ematics.HeenjoyedalongcareerasaDistinguishedMemberoftheTechnicalStaffatAT&T
BellLaboratories(andAT&TLaboratories)inMonmouthCounty,NewJersey.Whileworking
atBellLabs,hetaughtatMonmouthUniversity,teachingcoursesindiscretemathematics,cod-
ingtheory,anddatasecurity.AfterleavingAT&TLabs,hebecameavisitingresearchprofessor
ofcomputerscienceatMonmouthUniversity,wherehehastaughtcoursesinalgorithmdesign,
computersecurityandcryptography,anddiscretemathematics.
Dr.Rosenhaspublishednumerousarticlesinprofessionaljournalsonnumbertheoryand
onmathematicalmodeling.HeistheauthorofthewidelyusedElementaryNumberTheoryand
ItsApplications,publishedbyPearson,currentlyinitssixthedition,whichhasbeentranslated
intoChinese.HeisalsotheauthorofDiscreteMathematicsandItsApplications,publishedby
McGraw-Hill,currentlyinitseighthedition.DiscreteMathematicsandItsApplicationshassold
morethan450,000copiesinNorthAmericaduringitslifetime,andhundredsofthousandsof
copiesthroughouttherestoftheworld.Thisbookhasalsobeentranslatedintomanylanguages,
includingSpanish,French,Portuguese,Greek,Chinese,Vietnamese,andKorean.Heisalsoco-
authorofUNIX:TheCompleteReference;UNIXSystemVRelease4:AnIntroduction;andBest
UNIX Tips Ever, all published by Osborne McGraw-Hill. These books have sold more than
150,000copies,withtranslationsintoChinese,German,Spanish,andItalian.Dr.Rosenisalso
the editor of both the first and second editions (published in 1999 and 2018, respectively) of
the Handbook of Discrete and Combinatorial Mathematics, published by CRC Press. He has
served as the advisory editor of the CRC series of books in discrete mathematics, sponsoring
morethan70volumesondiverseaspectsofdiscretemathematics,manyofwhichareintroduced
inthisbook.HeisanadvisoryeditorfortheCRCseriesofmathematicstextbooks,wherehehas
helpedmorethan30authorswritebettertexts.Dr.RosenservesasanAssociateEditorforthe
journalDiscreteMathematics,wherehehandlespapersinmanyareas,includinggraphtheory,
enumeration,numbertheory,andcryptography.
Dr. Rosen has had a longstanding interest in integrating mathematical software into the
educational and professional environments. He has worked on several projects with Waterloo
MapleInc.’sMapleTMsoftwareinboththeseareas.Dr.Rosenhasdevotedagreatdealofenergy
toensuringthattheonlinehomeworkforDiscreteMathematicsanditsApplicationsisasuperior
teachingtool.Dr.Rosenhasalsoworkedwithseveralpublishingcompaniesontheirhomework
deliveryplatforms.
At Bell Laboratories and AT&T Laboratories, Dr. Rosen worked on a wide range of
projects, including operations research studies, product line planning for computers and data
communicationsequipment,technologyassessmentandinnovation,andmanyotherefforts.He
helped plan AT&T’s products and services in the area of multimedia, including video com-
munications, speech recognition, speech synthesis, and image networking. He evaluated new
technologyforusebyAT&Tanddidstandardsworkintheareaofimagenetworking.Healsoin-
ventedmanynewservices,andholdsmorethan70patents.Oneofhismoreinterestingprojects
involved helping evaluate technology for the AT&T attraction that was part of EPCOT Cen-
ter.AfterleavingAT&T,Dr.RosenhasworkedasatechnologyconsultantforGoogleandfor
AT&T.
vi
Preface
I
nwriting this book, I was guided by mylong-standing experience and interest in teaching
discretemathematics.Forthestudent,mypurposewastopresentmaterialinaprecise,read-
able manner, with the concepts and techniques of discrete mathematics clearly presented and
demonstrated. My goal was to show the relevance and practicality of discrete mathematics to
students, who are often skeptical. I wanted to give students studying computer science all of
themathematicalfoundationstheyneedfortheirfuturestudies.Iwantedtogivemathematics
students an understanding of important mathematical concepts together with a sense of why
these concepts are important for applications. And most importantly, I wanted to accomplish
thesegoalswithoutwateringdownthematerial.
Fortheinstructor,mypurposewastodesignaflexible,comprehensiveteachingtoolusing
provenpedagogicaltechniquesinmathematics.Iwantedtoprovideinstructorswithapackage
ofmaterialsthattheycouldusetoteachdiscretemathematicseffectivelyandefficientlyinthe
most appropriate manner for their particular set of students. I hope that I have achieved these
goals.
I have been extremely gratified by the tremendous success of this text, including its use
by more than one million students around the world over the last 30 years and its translation
into many different languages. The many improvements in the eighth edition have been made
possiblebythefeedbackandsuggestionsofalargenumberofinstructorsandstudentsatmany
ofthemorethan600NorthAmericanschools,andatmanyuniversitiesindifferentpartsofthe
world,wherethisbookhasbeensuccessfullyused.Ihavebeenabletosignificantlyimprovethe
appealandeffectivenessofthisbookeditiontoeditionbecauseofthefeedbackIhavereceived
andthesignificantinvestmentsthathavebeenmadeintheevolutionofthebook.
Thistextisdesignedforaone-ortwo-termintroductorydiscretemathematicscoursetaken
bystudentsinawidevarietyofmajors,includingmathematics,computerscience,andengineer-
ing.Collegealgebraistheonlyexplicitprerequisite,althoughacertaindegreeofmathematical
maturityisneededtostudydiscretemathematicsinameaningfulway.Thisbookhasbeende-
signedtomeettheneedsofalmostalltypesofintroductorydiscretemathematicscourses.Itis
highlyflexibleandextremelycomprehensive.Thebookisdesignednotonlytobeasuccessful
textbook,butalsotoserveasavaluableresourcestudentscanconsultthroughouttheirstudies
andprofessionallife.
Goals of a Discrete Mathematics Course
A discrete mathematics course has more than one purpose. Students should learn a particular
setofmathematicalfactsandhowtoapplythem;moreimportantly,suchacourseshouldteach
students how to think logically and mathematically. To achieve these goals, this text stresses
mathematicalreasoningandthedifferentwaysproblemsaresolved.Fiveimportantthemesare
interwoveninthistext:mathematicalreasoning,combinatorialanalysis,discretestructures,al-
gorithmicthinking, andapplicationsandmodeling.Asuccessfuldiscretemathematicscourse
shouldcarefullyblendandbalanceallfivethemes.
1. MathematicalReasoning:Studentsmustunderstandmathematicalreasoninginordertoread,
comprehend, and construct mathematical arguments. This text starts with a discussion of
mathematicallogic,whichservesasthefoundationforthesubsequentdiscussionsofmethods
ofproof.Boththescienceandtheartofconstructingproofsareaddressed.Thetechniqueof
vii
viii Preface
mathematicalinductionisstressedthroughmanydifferenttypesofexamplesofsuchproofs
andacarefulexplanationofwhymathematicalinductionisavalidprooftechnique.
2. Combinatorial Analysis:Animportantproblem-solving skillistheabilitytocountorenu-
merateobjects.Thediscussionofenumerationinthisbookbeginswiththebasictechniques
ofcounting.Thestressisonperformingcombinatorialanalysistosolvecountingproblems
andanalyzealgorithms,notonapplyingformulae.
3. Discrete Structures: A course in discrete mathematics should teach students how to work
with discrete structures, which are the abstract mathematical structures used to represent
discrete objects and relationships between these objects. These discrete structures include
sets,permutations,relations,graphs,trees,andfinite-statemachines.
4. Algorithmic Thinking: Certain classes of problems are solved by the specification of an
algorithm. After an algorithm has been described, a computer program can be constructed
implementingit.Themathematicalportionsofthisactivity,whichincludethespecification
of the algorithm, the verification that it works properly, and the analysis of the computer
memoryandtimerequiredtoperformit,areallcoveredinthistext.Algorithmsaredescribed
usingbothEnglishandaneasilyunderstoodformofpseudocode.
5. ApplicationsandModeling:Discretemathematicshasapplicationstoalmosteveryconceiv-
able area of study. There are many applications to computer science and data networking
in this text, as well as applications to such diverse areas as chemistry, biology, linguistics,
geography,business,andtheInternet.Theseapplicationsarenaturalandimportantusesof
discrete mathematics and are not contrived. Modeling with discrete mathematics is an ex-
tremelyimportantproblem-solvingskill,whichstudentshavetheopportunitytodevelopby
constructingtheirownmodelsinsomeoftheexercises.
Changes in the Eighth Edition
Although the seventh edition has been an extremely effective text, many instructors have re-
questedchangestomakethebookmoreusefultothem.Ihavedevotedasignificantamountof
timeandenergytosatisfytheirrequestsandIhaveworkedhardtofindmyownwaystoimprove
thebookandtokeepitup-to-date.
The eighth edition includes changes based on input from more than 20 formal reviewers,
feedbackfromstudentsandinstructors,andmyinsights.TheresultisaneweditionthatIex-
pectwillbeamoreeffectiveteachingtool.Numerouschangesintheeightheditionhavebeen
designedtohelpstudentslearnthematerial.Additionalexplanationsandexampleshavebeen
added to clarify material where students have had difficulty. New exercises, both routine and
challenging, have been added. Highly relevant applications, including many related to the In-
ternet, to computer science, and to mathematical biology, have been added. The companion
websitehasbenefitedfromextensivedevelopment;itnowprovidesextensivetoolsstudentscan
usetomasterkeyconceptsandtoexploretheworldofdiscretemathematics.Furthermore,addi-
tionaleffectiveandcomprehensivelearningandassessmenttoolsareavailable,complementing
thetextbook.
Ihopethatinstructorswillcloselyexaminethisneweditiontodiscoverhowitmightmeet
their needs. Although it is impractical to list all the changes in this edition, a brief list that
highlightssomekeychanges,listedbythebenefitstheyprovide,maybeuseful.
ChangesintheEighthEdition
This new edition of the book includes many enhancements, updates, additions, and edits, all
designed to make the book a more effective teaching tool for a modern discrete mathematics
course.Instructorswhohaveusedthebookpreviouslywillnoticeoverallchangesthathavebeen
madethroughoutthebook,aswellasspecificchanges.Themostnotablerevisionsaredescribed
here.
Preface ix
OverallChanges
▶ Expositionhasbeenimprovedthroughoutthebookwithafocusonprovidingmoreclarity
tohelpstudentsreadandcomprehendconcepts.
▶ Many proofs have been enhanced by adding more details and explanations, and by re-
mindingthereaderoftheproofmethodsused.
▶ Newexampleshavebeenadded,oftentomeetneedsidentifiedbyreviewersortoillus-
tratenewmaterial.Manyoftheseexamplesarefoundinthetext,butothersareavailable
onlyonthecompanionwebsite.
▶ Many new exercises, both routine and challenging, address needs identified by in-
structors or cover new material, while others strengthen and broaden existing exercise
sets.
▶ More second and third level heads have been used to break sections into smaller co-
herentparts,andanewnumberingschemehasbeenusedtoidentifysubsectionsofthe
book.
▶ Theonlineresourcesforthisbookhavebeengreatlyexpanded,providingextensivesup-
port for both instructors and students. These resources are described later in the front
matter.
TopicCoverage
▶ Logic Severallogicalpuzzleshavebeenintroduced.Anewexampleexplainshowto
modelthen-queensproblemasasatisfiabilityproblemthatisbothconciseandaccessible
tostudents.
▶ Settheory Multisetsarenowcoveredinthetext.(Previouslytheywereintroducedin
theexercises.)
▶ Algorithms Thestringmatchingproblem,animportantalgorithmformanyapplica-
tions,includingspellchecking,key-wordsearching,string-matching,andcomputational
biology, is now discussed. The brute-force algorithm for solving string-matching exer-
cisesispresented.
▶ Numbertheory Theneweditionincludesthelatestnumericalandtheoreticdiscov-
eriesrelatingtoprimesandopenconjecturesaboutthem.TheextendedEuclideanalgo-
rithm,aone-passalgorithm,isnowdiscussedinthetext.(Previouslyitwascoveredin
theexercises.)
▶ Cryptography Theconceptofhomomorphicencryption,anditsimportancetocloud
computing,isnowcovered.
▶ Mathematical induction The template for proofs by mathematical induction has
been expanded. It is now placed in the text before examples of proof by mathematical
induction.
▶ Countingmethods Thecoverageofthedivisionruleforcountinghasbeenexpanded.
▶ Data mining Association rules—key concepts in data mining—are now discussed
in the section on n-ary relations. Also, the Jaccard metric, which is used to find the
distance between two sets and which is used in data mining, is introduced in the
exercises.
▶ Graph theory applications A new example illustrates how semantic networks, an
importantstructureinartificialintelligence,canbemodeledusinggraphs.