16
DISCRETE MATHEMATICS AND STRUCTURES

Sample

Embed Size (px)

DESCRIPTION

discrete math book

Citation preview

  • DISCRETE MATHEMATICSAND STRUCTURES

  • UNIVERSITY SCIENCE PRESS(An Imprint of Laxmi Publications (P) Ltd.)

    BANGALORE NNNNN CHENNAI NNNNN COCHIN NNNNN GUWAHATI NNNNN HYDERABAD

    JALANDHAR NNNNN KOLKATA NNNNN LUCKNOW NNNNN MUMBAI NNNNN RANCHINEW DELHI NNNNN BOSTON, USA

    DISCRETEMATHEMATICS

    ANDSTRUCTURES

    [For B.E./B.Tech. (Computer Science), B.C.A., M.C.A., M.Sc. (Computer Science)]

    By

    Dr. Satinder Bal GuptaB.Tech. (CSE), MCA, UGCNET, Ph.D (CS)

    Professor, Deptt. of Computer Science & ApplicationsVaish College of Engineering, Rohtak,

    Haryana

  • Published by :

    UNIVERSITY SCIENCE PRESS(An Imprint of Laxmi Publications Pvt. Ltd.)

    113, Golden House, Daryaganj,New Delhi-110002

    Phone : 011-43 53 25 00Fax : 011-43 53 25 28

    [email protected]

    Price : ` 450.00 Only. First Edition : 2002, Second Edition : 2004,Third Edition : 2006, Fourth Edition : 2007,

    Fifth Edition : 2008, Reprint : 2013, Sixth Edition : 2014

    OFFICES

    Bangalore 080-26 75 69 30 Kolkata 033-22 27 43 84 Chennai 044-24 34 47 26 Lucknow 0522-220 99 16 Cochin 0484-237 70 04, 405 13 03 Mumbai 022-24 91 54 15, 24 92 78 69 Guwahati 0361-251 36 69, 251 38 81 Hyderabad 040-24 65 23 33 Ranchi 0651-221 47 64 Jalandhar 0181-222 12 72

    UDM-9232-450-DISCRETE MATH & STRU-GUP C16452/08/09Typeset at : Excellent Graphics, Delhi. Printed at :

    Copyright 2013 by Laxmi Publications Pvt. Ltd. All rights reserved with thePublishers. 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 or otherwise without the prior written permission of the publisher.

  • To My

    Little DaughterARSHITA

  • PREFACE

    It gives me a great pleasure in bringing out the Sixth Edition of the book DiscreteMathematics and Structures. The necessity for Discrete Structure in Computer Science arisesdue to selection of certain applications from various areas of the field. As the subject DiscreteMathematics or Discrete Structures is taught in most Engineering Institutions, the students facea lot of problems in this subject as no book covers the whole syllabi and also due to lack of solvedproblems in the various books. This book is based on the experience gained in teaching a course onthe subject. My intention is to cover all topics in the book with a number of solved problems andsolutions of the questions from the previous question papers of different universities and othercompetitive examinations. I am sure that this book will help a student to grip each topic withoutany difficulty.

    What is New in the Sixth EditionMany changes have been made in the sixth edition as the goal is to expand the coverage of

    topics and more examples. New chapters has been added on series and sequences, Automation and languages, Boolean

    algebra etc. Many new sections in every chapter. Additional problems in every chapter. Multiple choice questions and unsolved exercises.I would seek the indulgence of my readers in intimating me about any error or shortcomings

    noticed by them in the book.

    AUTHOR

  • How to Study Discrete Structures

    1. How to Read Math Read slowly & actively:

    Make sure you understand everything before reading anything new After reading each sentence, ask yourself:

    Why? Do I agree?

    Algorithm for Slow & Active ReadingSee next page,

    2. How to Take Notes in Class Copy as much as possible from the board or screen. Copy as accurately as possible.

    Include what Teacher say but dont write. Use abbreviations Dont necessarily try to understand! Write down any questions you have.

    Then re-write your notes at home, neatly & without abbreviations That is when you should try to understand!

    3. How to Practice Doing Math Do the odd-numbered problems from Text. Work with 1 or 2 other students in small study groups;

    check each others work. But dont cheat!

    4. How to Study for Tests Use your recopied class notes, together with your highlighted text and notebook, to

    make an outline of the material. Solve lots of sample problems.Golden Rule: Never read Mathematics. Always solve problems by writing while reading.

  • Algorithm for Slow& Active Reading

    HOW TO READ (A COMPUTER SCIENCE TEXT)Algorithm by William J. Rapaport

    WHILE there is a next.sentence to read, DO:

    BEGIN (* while *)

    1. Read it, SLOWLY;

    2. IF you do not understand it, THEN

    BEGIN (* if *)

    (a) re-read the previous material, SLOWLY;

    (b) re-read the incomprehensible sentence, SLOWLY;

    (c) IF you still dont understand it, THEN

    ask a fellow student to explain it;

    (d) IF you still dont understand it, THEN

    Ask your Teacher to explain it;

    (e) IF you are in an upper-level course & you still dontunderstand it, THEN

    write a paper about it (!)

    END (* IF *)

    END; (* while *)

    Since there is no next sentence (because the Boolean test in the WHILE is false), youveunderstood the text!

  • ACKNOWLEDGMENTS

    It is difficult to acknowledge adequately the help & encouragement, I have received incompletion and final publication of this work which has been exercising my mind since long. First,I must express my gratitude to the Professors & Lecturers of the Sant Longowal Institute ofEngg. & Technology, Longowal (Punjab) where I learnt the elements of Discrete Mathematics andStructures during the course of my various assignments on the subject.

    I also owe a debt of gratitude to the Esteemed Management of Vaish College of Engg.,Rohtak who has been a source of inspiration to me in attempting this work. I should also expressmy grateful thanks to my associates with whom I had occasions to discuss the work of my book atlength which are in large numbers. I must express my indebtness to the students who have helpedme in fixing the pattern of emphasis & in correction of proofs, to mention the least are ManishGoel, Ashish Goel & Manish Kansal.

    Last, but not the least, I express my appreciation to my wife, Monika Gupta for her assistanceand constant encouragement without which the venture would have failed.

    AUTHOR

  • Chapters Page No.

    1. SETS 135

    1.1 Definition ..................................................................................................................11.2 Set Formation ..........................................................................................................11.3 Standard Notations ..................................................................................................11.4 Various Types of Sets ..............................................................................................21.5 Operations on Sets ...................................................................................................71.6 Algebra of Sets .........................................................................................................81.7 Cardinality of a Set ............................................................................................... 121.8 Venn Diagrams ...................................................................................................... 131.9 Multisets ................................................................................................................. 141.10 Ordered Pairs ......................................................................................................... 151.11 Cartesian Product of Two Sets ............................................................................. 15Solved Problems...............................................................................................................17Multiple Choice Questions ...............................................................................................26Exercises ........................................................................................................................... 27

    2. PRINCIPLE OF INCLUSION AND EXCLUSION 3647

    2.1 First Principle ........................................................................................................ 362.2 Inclusion-Exclusion Principle in General ............................................................. 37Solved Problems...............................................................................................................37Multiple Choice Questions ...............................................................................................42Exercises ........................................................................................................................... 42

    3. MATHEMATICAL INDUCTION 4864

    3.1 Principle ................................................................................................................. 483.2 Working Rule ......................................................................................................... 483.3 Peanos Axioms ...................................................................................................... 48

    CONTENTS

  • Chapters Page No.

    Solved Problems...............................................................................................................49Multiple Choice Questions ...............................................................................................59Exercises ........................................................................................................................... 60

    4. RELATIONS 65119

    4.1 Binary Relation ...................................................................................................... 654.2 Complement of a Relation ..................................................................................... 664.3 Inverse of a Relation ............................................................................................. 664.4 Representation of Relations ................................................................................... 674.5 Composition of Relations........................................................................................ 694.6 Path in Relations ................................................................................................... 714.7 Composition of Paths ............................................................................................. 764.8 Computer Representation of Relations .................................................................. 774.9 Representation of Relation in Computer ............................................................... 784.10 Properties of Relations ........................................................................................... 824.11 Closure Properties of Relations ............................................................................. 854.12 Warshalls Algorithm to Find Transitive Closure ............................................... 874.13 Equivalence Relations ............................................................................................ 884.14 Partial Order Relation ........................................................................................... 894.15 Total Order Relation .............................................................................................. 904.16 Partition ................................................................................................................. 904.17 Equivalence Class .................................................................................................. 914.18 Circular Relation .................................................................................................... 91Solved Problems...............................................................................................................92Multiple Choice Questions ............................................................................................. 103Exercises ......................................................................................................................... 106

    5. FUNCTIONS 120158

    5.1 Definition .............................................................................................................. 1205.2 Functions as a Set .............................................................................................. 1205.3 Domain of a Function ......................................................................................... 1205.4 Co-domain of a Function ..................................................................................... 1215.5 Image of an Element ........................................................................................... 1215.6 Range of a Function ............................................................................................ 1215.7 Representation of a Function .............................................................................. 1225.8 Everywhere Defined Function ............................................................................. 122

  • Chapters Page No.

    5.9 Types of Functions .............................................................................................. 1235.10 Equal Functions ................................................................................................... 1265.11 Identity Functions ............................................................................................... 1265.12 Invertible (Inverse) Functions ............................................................................. 1275.13 Composition of Functions .................................................................................... 1275.14 Functions Applicable in Computer Science ........................................................ 1295.15 Permutation Functions ........................................................................................ 133Solved Problems............................................................................................................. 139Multiple Choice Questions ............................................................................................. 148Exercises ......................................................................................................................... 150

    6. ALGORITHMS 159181

    6.1 Algorithm ............................................................................................................. 1596.2 Characteristics of Algorithms ............................................................................. 1596.3 Trace of the Algorithm ........................................................................................ 1606.4 Pseudo Code ......................................................................................................... 1606.5 Analysis (complexity) of Algorithms ................................................................... 1606.6 Asymptotic Notations ........................................................................................... 1616.7 Big-oh (O) Notation .............................................................................................. 1616.8 Omega () Notation ............................................................................................ 1626.9 Theta () Notation ............................................................................................... 1626.10 Recursive Algorithms ........................................................................................... 163Solved Problems............................................................................................................. 164Multiple Choice Questions ............................................................................................. 170Exercises ......................................................................................................................... 171

    7. GRAPHS 182244

    7.1 Basic Terminology ............................................................................................... 1827.2 Subgraph .............................................................................................................. 1897.3 Cut Set ................................................................................................................. 1917.4 Cut Points or Cut Vertices ................................................................................. 1917.5 Bridge (Cut Edges) ............................................................................................... 1927.6 Isomorphic Graphs ............................................................................................... 1947.7 Homeomorphic Graphs ........................................................................................ 1957.8 Directed Graphs ................................................................................................... 1967.9 Labeled Graphs .................................................................................................... 199

  • Chapters Page No.

    7.10 Weighted Graphs ................................................................................................. 1997.11 Multigraph ........................................................................................................... 2007.12 Representation of Graphs .................................................................................... 2017.13 Other Important Graphs ..................................................................................... 2047.14 Graph Colouring .................................................................................................. 2137.15 Shortest Path in Weighted Graphs .................................................................... 2167.16 Travelling Salesman Problem ............................................................................. 218Solved Problems............................................................................................................. 220Multiple Choice Questions ............................................................................................. 231Exercises ......................................................................................................................... 234

    8. TREES 245300

    8.1 General Trees ....................................................................................................... 2458.2 Directed Trees ...................................................................................................... 2458.3 Ordered Trees ...................................................................................................... 2468.4 Rooted Trees ......................................................................................................... 2468.5 Path Length of a Vertex ..................................................................................... 2478.6 Forest .................................................................................................................... 2488.7 Binary Tree .......................................................................................................... 2488.8 Infix, Prefix and Postfix Notations ..................................................................... 2518.9 Complete Binary Tree .......................................................................................... 2588.10 Full Binary Tree .................................................................................................. 2588.11 Traversing Binary Trees ..................................................................................... 2618.12 Algorithms to Draw Binary Trees ...................................................................... 2628.13 Binary Search Trees ............................................................................................ 2678.14 Spanning Tree ...................................................................................................... 2698.15 Game Trees .......................................................................................................... 272Solved Problems............................................................................................................. 276Multiple Choice Questions ............................................................................................. 288Exercises ......................................................................................................................... 291

    9. PROPOSITIONAL CALCULUS 301341

    9.1 Proposition ............................................................................................................ 3019.2 Combination of Propositions ................................................................................ 3019.3 Principle of Duality ............................................................................................. 3079.4 Equivalence of Propositions ................................................................................. 308

  • Chapters Page No.

    9.5 Tautologies ........................................................................................................... 3089.6 Contradiction ........................................................................................................ 3099.7 Contingency .......................................................................................................... 3099.8 Functionally Complete Sets of Connectives ........................................................ 3119.9 Argument ............................................................................................................. 3129.10 Existential Quantifier .......................................................................................... 3219.11 Universal Quantifier ............................................................................................ 3219.12 Negation of Quantified Propositions ................................................................... 3229.13 Propositions with Multiple Quantifiers .............................................................. 323Solved Problems............................................................................................................. 323Multiple Choice Questions ............................................................................................. 333Exercises ......................................................................................................................... 335

    10. PROBABILITY THEORY 342361

    10.1 Important Terms Related with Probability ........................................................ 34210.2 Probability Definition ........................................................................................... 34310.3 Addition Theorem................................................................................................. 34310.4 Multiplication Theorem ....................................................................................... 34710.5 Conditional Probability ........................................................................................ 350Solved Problems............................................................................................................. 354Multiple Choice Questions ............................................................................................. 358Exercises ......................................................................................................................... 359

    11. COUNTING TECHNIQUES 362391

    11.1 First Counting Principle ..................................................................................... 36211.2 Second Counting Principle .................................................................................. 36511.3 Define Factorial N ............................................................................................... 36611.4 Permutation ......................................................................................................... 36711.5 Combination ......................................................................................................... 37311.6 The Pigeonhole Principle ..................................................................................... 376Solved Problems............................................................................................................. 377Multiple Choice Questions ............................................................................................. 382Exercises ......................................................................................................................... 384

  • Chapters Page No.

    12. SEQUENCES AND SERIES 392416

    12.1 Sequences ............................................................................................................. 39212.2 Representation of Sequences ................................................................................ 39312.3 Sequences of Symbols or Letters ........................................................................ 39312.4 Set Corresponding to a Sequence ........................................................................ 39412.5 Series .................................................................................................................... 394Solved Problems............................................................................................................. 405Multiple Choice Questions ............................................................................................. 413Exercises ......................................................................................................................... 414

    13. RECURRENCE RELATIONS AND GENERATING FUNCTIONS 417447

    13.1 Definition .............................................................................................................. 41713.2 Order of the Recurrence Relation ....................................................................... 41713.3 Degree of the Difference Equation ...................................................................... 41713.4 Linear Recurrence Relations with Constant Coefficients .................................. 41813.5 Total Solution ....................................................................................................... 42513.6 Generating Functions .......................................................................................... 429Solved Problems............................................................................................................. 434Multiple Choice Questions ............................................................................................. 444Exercises ......................................................................................................................... 444

    14. ALGEBRAIC STRUCTURES 448482

    14.1 Definition .............................................................................................................. 44814.2 Binary Operation ................................................................................................. 44814.3 Tables of Operation.............................................................................................. 44914.4 Properties of Binary Operations ......................................................................... 44914.5 Semigroup............................................................................................................. 45214.6 Congruence Relation ............................................................................................ 45414.7 Monoid .................................................................................................................. 45514.8 Group .................................................................................................................... 45514.9 Abelian Group ...................................................................................................... 45914.10 Product of Groups ................................................................................................ 46014.11 Cyclic Groups ....................................................................................................... 46114.12 Cosets.................................................................................................................... 46214.13 Lagranges Theorem ............................................................................................ 463