1DavidLiben-NowellDepartmentofComputerScienceCarletonCollegeDiscreteMathematicsforComputerScienceor(ABitof)TheMaththatComputerScientistsNeedtoKnow
VP AND EDITORIAL DIRECTOR
SENIOR DIRECTOR
ACQUISITIONS EDITOR
EDITORIAL MANAGER
CONTENT MANAGEMENT DIRECTOR
CONTENT MANAGER
SENIOR CONTENT SPECIALIST
PRODUCTION EDITOR
PHOTO RESEARCHER
COVER PHOTO CREDIT
Laurie Rosatone
Don Fowley
Linda Ratts
Gladys Soto
Lisa Wojcik
Nichole Urban
Nicole Repasky
Rajeshkumar Nallusamy
Billy Ray
© slobo/Getty Images, Inc.
This book was set in TeXGyrePagella 10/12 by SPi Global and printed and bound by Strategic Content Imaging.
This book is printed on acid free paper. ∞
Founded in 1807, John Wiley & Sons, Inc. has been a valued source of knowledge and understanding for more
than 200 years, helping people around the world meet their needs and fulfill their aspirations. Our company is
built on a foundation of principles that include responsibility to the communities we serve and where we live
and work. In 2008, we launched a Corporate Citizenship Initiative, a global effort to address the environmental,
social, economic, and ethical challenges we face in our business. Among the issues we are addressing are carbon
impact, paper specifications and procurement, ethical conduct within our business and among our vendors,
and community and charitable support. For more information, please visit our website: www.wiley.com/go/
citizenship.
Copyright © 2018, John Wiley & Sons, Inc. All rights reserved. No part of this publication may be reproduced,
stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying,
recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of the Publisher, or authorization through payment
of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA
01923 (Web site: www.copyright.com). Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, (201) 748-6011,
fax (201) 748-6008, or online at: www.wiley.com/go/permissions.
Evaluation copies are provided to qualified academics and professionals for review purposes only, for use
in their courses during the next academic year. These copies are licensed and may not be sold or transferred
to a third party. Upon completion of the review period, please return the evaluation copy to Wiley. Return
instructions and a free of charge return shipping label are available at: www.wiley.com/go/returnlabel. If you
have chosen to adopt this textbook for use in your course, please accept this book as your complimentary desk
copy. Outside of the United States, please contact your local sales representative.
ISBN: 978-1-118-06553-2 (PBK)
ISBN: 978-1-119-07073-3 (EVALC)
Library of Congress Cataloging in Publication Data:
Liben-Nowell, David, author.
Title: Discrete mathematics for computer science / by David Liben-Nowell.
Description: Hoboken, NJ : John Wiley & Sons, 2017. | Includes index. |
Identifiers: LCCN 2017025007 (print) | LCCN 2017035974 (ebook) | ISBN
9781119397199 (pdf) | ISBN 9781119397113 (epub) | ISBN 9781118065532 (pbk.)
Subjects: LCSH: Computer science—Mathematics.
Classification: LCC QA76.9.M35 (ebook) | LCC QA76.9.M35 L53 2017 (print) |
DDC 004.01/51—dc23
LC record available at https://lccn.loc.gov/2017025007
The inside back cover will contain printing identification and country of origin if omitted from this page. In
addition, if the ISBN on the back cover differs from the ISBN on this page, the one on the back cover is correct.
ToMDSWM,withnever-endingappreciation,andinlovingmemoryofmygrandfather,JayLiben,whobroughtmorejoy,curiosity,andkvetchingtothisworldthananyoneelseIknow.
Contents1OnthePointofthisBook1012BasicDataTypes2012.1WhyYouMightCare2022.2Booleans,Numbers,andArithmetic2032.3Sets:UnorderedCollections2222.4Sequences,Vectors,andMatrices:OrderedCollections2372.5Functions2532.6ChapterataGlance2703Logic3013.1WhyYouMightCare3023.2AnIntroductiontoPropositionalLogic3033.3PropositionalLogic:SomeExtensions3173.4AnIntroductiontoPredicateLogic3313.5PredicateLogic:NestedQuantifiers3493.6ChapterataGlance362
64Proofs4014.1WhyYouMightCare4024.2Error-CorrectingCodes4034.3ProofsandProofTechniques4234.4SomeExamplesofProofs4414.5CommonErrorsinProofs4584.6ChapterataGlance4695MathematicalInduction5015.1WhyYouMightCare5025.2ProofsbyMathematicalInduction5035.3StrongInduction5215.4RecursivelyDefinedStructuresandStructuralInduction5335.5ChapterataGlance5466AnalysisofAlgorithms6016.1WhyYouMightCare6026.2Asymptotics6036.3AsymptoticAnalysisofAlgorithms6176.4RecurrenceRelations:AnalyzingRecursiveAlgorithms6316.5RecurrenceRelations:TheMasterMethod6476.6ChapterataGlance6577NumberTheory7017.1WhyYouMightCare7027.2ModularArithmetic7037.3PrimalityandRelativePrimality7177.4MultiplicativeInverses7347.5Cryptography7457.6ChapterataGlance756