24
Discrete Mathematics Unit 3 Sikkim Manipal University Page No: 75 Unit 3 Combinatorics Structure 3.1 Introduction Objectives 3.2 Principles of Counting 3.3 Generating Function 3.4 Partitions and Compositions 3.5 Orderings 3.6 Principle of Inclusion and Exclusion Self Assessment Questions (SAQ’s) 3.7 Summary 3.8 Terminal Questions 3.9 Answers 3.1 Introduction Combinatorics is the branch of discrete mathematics concerned with counting problems. Techniques for counting are important in Mathematics and Computer Science especially in the analysis of algorithms and in the theory of probability. In this unit we present the counting techniques, particularly those for permutations and combinations. We also look into these aspects using the generating function which is the advanced tool to analyze the computer programs. Further we discuss the applications of the principle of inclusion and exclusion. Objectives At the end of the unit the student must be able to: Learn the principles of counting with certain natural objects. Apply the techniques of generating function to partitions and compositions. Write the permutations in lexicographic and reverse lexicographic order. Apply the principles of inclusion and exclusion to various models.

MC0063(A)-Unit3-fi

Embed Size (px)

DESCRIPTION

File

Citation preview

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:75

    Unit3 CombinatoricsStructure

    3.1 Introduction

    Objectives

    3.2 PrinciplesofCounting

    3.3 GeneratingFunction

    3.4 PartitionsandCompositions

    3.5 Orderings

    3.6 PrincipleofInclusionandExclusion

    SelfAssessmentQuestions(SAQs)

    3.7 Summary

    3.8 TerminalQuestions

    3.9 Answers

    3.1Introduction

    Combinatorics is the branch of discrete mathematics concerned with

    countingproblems. Techniquesforcountingare important inMathematics

    andComputer Scienceespecially in theanalysis of algorithmsand in the

    theory of probability. In this unit we present the counting techniques,

    particularly those for permutations and combinations. We also look into

    theseaspectsusing thegenerating functionwhich is theadvanced tool to

    analyzethecomputerprograms.Furtherwediscusstheapplicationsofthe

    principleofinclusionandexclusion.

    Objectives

    Attheendoftheunitthestudentmustbeableto:

    Learntheprinciplesofcountingwithcertainnaturalobjects.

    Applythetechniquesofgeneratingfunctiontopartitionsandcompositions.

    Write thepermutationsinlexicographicandreverselexicographicorder.

    Applytheprinciplesofinclusionandexclusiontovariousmodels.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:76

    3.2PrincipleofCounting

    3.2.1(i). RuleofSum:IftheobjectAmaybechooseninmways,andBin

    nways,theneitherAorB(exactlyone)maybechooseninm+nways.

    Thiscanbegeneralisedforanypobjects.

    (ii).RuleofProduct: If theobjectAmaybe choosen inmwaysand the

    objectBinnways,thenbothAandBmaybechooseninthisorderinmn

    ways.Thiscanbegeneralisedforanypobjects.

    3.2.2Example

    If thereare42ways toselecta representativeforclassAand50ways to

    selectarepresentativefortheclassB,then

    i) By the rule of product, there are 42 50 ways to select the

    representativeforboththeclassAandclassB

    ii) Bytheruleofsum,therewillbe42+50waystoselectarepresentative

    foreitherclassAorclassB.

    3.2.3Example

    Supposea licenseplatecontains2 lettersfollowedbyfourdigits,with the

    firstdigitisnotzero.Howmanydifferentlicenseplatescanbeprinted?.

    Solution:Eachlettercanbeprintedin26differentways.

    Sincethefirstdigitisotherthanzero,thiscanbeselectedin9ways.

    Second,thirdandfourthdigitscanbeselectedin10ways.

    Thereforebytheruleofproduct,thereare 26 26 9 10 10 10ways.

    Specialcase:Allaredistinct

    Firstlettercanbeprintedin26ways.

    Secondlettercanbeprintedin25ways.

    Firstdigitcanbeprintedin9ways(otherthan0).

    Seconddigitcanbeprintedin9ways(anyonefrom0to9exceptchoosen

    firstdigit)

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:77

    Thirddigitcanbeprintedin8ways

    Fourthdigitcanbeprintedin7ways.

    Thereforebytheruleofproduct,thereare26 25 9 9 8 7ways.

    3.2.4Permutationofdistinctthings

    Letusrecollectthatthefirstofthemembersofan rpermutationofndistinctthingsmaybechooseninnways.Thesecondischoosenin(n1)ways,,therth ischooseninn(n1)ways.

    So by the repeated application of product rule, the number required is

    n(n1).(n(r 1))ways,n r,itisdenotedbyp(n,r).

    Ifr=n,thenp(n,n)=n(n1)(nn+1)=n (n 1)2.1=n!.

    Thereforep(n,r)=1.2)...rn(

    1.2)...1r(n)...(2n)(1n(n -

    - - -

    =)!rn(

    !n -

    =)rn,rn(p

    )n,n(p - -

    or p(n,n)=p(n,r).p(n r,nr).

    3.2.5Problem

    Provethatp(n,r)=p(n1,r)+r.p(n1,r1)

    Solution:Writep(n,r)=n(n 1)(n(r1))

    =(n1)(n 2)..n(r1)[(nr)+r],whichis

    equaltop(n1,r)+r.p(n1,r 1),onmultiplication.

    3.2.6Note:

    i) The number of permutations of n objects taken r at a time with

    unlimited repetition, which is same as the number of ways of filling

    rblankspaceswithnobjects.Afterchoosingtheobjectinnways,the

    nextobjectcanalsobechoosenin nwaysandsoon. Therefore, in

    thiscasetherearen n . n=nr=U(n,r)ways.

    rtimes

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:78

    ii) Consider nobjectsofwhichm1 are first kind,m2 areof secondkind,

    .,mkareofkthkind,then nmk

    1ii =

    = .

    iii) Leta1,a2,,akberealnumbers.Considerthepower

    (a1+a2++ak)n=(a1+a2++ak)(a1+a2++ak)(a1+a2++ak).

    Afterperformingthisproductbutbeforecollecting like terms,a typical

    term in this product has the form 1 2 kn n n1 2 ka a ...a . The coefficient of

    1 2 kn n n1 2 ka a ...a aftercollectingliketermsisequaltothenumberofways

    ofpickingn1factorsequaltoa1andn2 factorsequaltoa2andsoon,as

    we multiply n copies of a1+ a2 + + ak. This is precisely the

    multinomialcoefficient

    1 2 k

    n

    n n ...n

    =!!....mm!m

    n!

    k21.

    3.2.7Theorem

    Thenumberofdistinguishable permutationsof nobjects inwhich the first

    object appears in m1 times, second object in m2 ways,. and so on, is

    !!....mm!mn!

    k21,wheremk isthekthobjectappearsinmk times.

    Proof:Letxbethenumberrequired.Inpermutationamongx,makem1all

    distinct. Since m1 objects can be permuted among themselves, one

    permutation will give rise to m1!. Therefore x permutations gives x.m1!

    permutations.Nowmakem2 identicalobjectsalldistinct.Thenwegetxm1!

    m2! Permutations of n objects in which m3 are alike, mk are alike.

    Continuing this process we get x.m1! m2! mk! as the number of

    permutationsofnobjectsofwhicharealldistinctandhenceequalton!.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:79

    Thereforex=!!....mm!m

    n!

    k21.

    3.2.8Example

    (i) Find the number of different letter arrangements can be formed using

    BHANUSHASHANK.

    Solution:Totalnumberoflettersn=13(withrepetitions)

    NumberofAs=3

    NumberofHs=3

    NumberofNs=2.

    NumberofSs=2

    AndthelettersB,U,K,eachis1.

    Thereforetherequirednumberofpermutationsis13!

    3!3!2!2!1!1!1!.

    (ii):Writethecoefficientofx3y2z2 in(x+y+z)9.

    Solution: This issameashowmanywaysonecanchoosexfrom three

    brackets,ayfromtwobracketsandazfromtwobracketsintheexpansion

    (x+y+z)(x+y+z)(x+y+z)(9times).

    Thiscanbedonein9 9!

    15120.322 3!2!2!

    = =

    3.2.9Note

    The r objects of each rcombination can be permuted among r! different

    rpermutations, eachofwhich corresponds to a single combination. If the

    number or rcombinations of n objects without repetition (denoted by

    C(n,r)). Then

    r!C(n,r)=p(n,r)=r)!(n

    n!

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:80

    C(n,r)=r!r)!(n

    n! =

    r

    n.

    Itcanbeeasilyverifiedthat C(n1,r1)+C(n1,r)=C(n,r).

    3.2.10Example

    Howmanywaysmayonerightandoneleftshoebeselectedfromsixpairs

    ofshoeswithoutobtainapair.

    Solution: Anyoneoftheleftshoecanbeselectedinsixways.Wehave

    fivechoiceforselectingarightshoewithoutobtainingapair.Thereforethe

    totalnumberofwaysselectingoneleftandonerightshoeis=6 5=30

    ways.

    3.2.11Example

    Anewnationalflagistobedesignedwithsixverticalstripsinyellow,green,

    blue,andred.Inhowmanywayscanthisbedonesothatnotwoadjacent

    stripshavethesamecolour.

    Solution:Thefirststripcanbeselectedinfourdifferentways.Sincenotwo

    adjacent stripshave the samecolour, the secondstripcanbe selected in

    threedifferentways.Inasimilarway,3rd ,4rth,5thand6thstripsareselected

    in three different ways.Therefore the total number of ways selecting the

    differentcoloursinthestripsare4 3 3 3 3 3=4 35=972ways.

    3.2.12Problem

    i) Howmanypositiveintegerslessthanonemillioncanbeformedusing

    7s8sand9sonly?

    ii) Howmanyusing0s,8sand9sonly?.

    Solution:

    i) Wefindthenumberofintegersusedfrom1to9,99,999.

    Numberofsingledigits(lessthan10)are7,8,9.

    Numberofintegersformedusingtwodigitsare3 3=32.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:81

    Similarly, numberof integerswith 3digits is3 3 3=33,, the

    numberofintegerswith6digitsis36.

    Therefore thetotalnumberofpositive integers less than1millioncan

    beformedusing7,8,9only=3+32+33+34+35+36=1092.

    ii) Number of positive integers containing one digit is 2 (zero is not

    considered)numberofpositiveintegerscontainingtwodigits=2 31.,

    andsoon,numberofpositiveintegerscontainingsixdigitsis2 35.

    Therefore the total number of integers containing 0, 8, 9 is = 2 + 2

    (3+32++35)=728.

    3.2.13Problem

    Findthesumofallthefourdigitnumberthatcanbeobtainedbyusingthe

    digits1,2,3,4onceineach.

    Solution:Thenumberofpermutations(arrangements)canbemadeusing

    4numbers (1,2,3,4) taking4atatimeisp(4,4)=0!4! =24.

    Eachnumberoccur6 times inunitplace,6 times in10th place,6 times in

    100thplace,6timesin1000place.

    Thereforesumofthenumbersintheunitplaceis = 6.1+6.2+6.3+6.4=60

    Totalsumofthedigitsinthe10thplace =60 10

    Totalsumofthedigitsinthe100thplace =60 100

    Totalsumofthedigitsinthe1000thplace =60 1000

    Thereforetotalsumofall24numbers =66,660.

    3.2.14Note

    Supposethatrselectionsaretobemadefromnitemswithoutregardtothe

    orderandthatunlimitedrepetitionsareallowed,assumingat leastrcopies

    ofnitems.Thenumberofwaysoftheseselectioncanbemadeis

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:82

    C(n+r1,r)=1)!(nr!

    1)!r(n+ .

    3.2.15Example

    Inhowmanywayscanaladywearfiveringsonthefingers(notthethumb)

    ofherrighthand?

    Solution:Therearefiveringsandfourfingers.Fiveringscanbepermuted

    in p (5, 5) ways. The number of unrestricted combinations of 4 objects

    taken5atatimeis

    - +

    5

    154=

    5

    8.Thereforethetotalnumberofways

    =5!

    5

    8=6720.

    3.3GeneratingFunctions

    Considerthethreedistinctobjectsa,bandcandformthepolynomial

    (1+ax)(1+bx)(1+cx)=1+(a+b+c)x+(ab+bc+ca)x2+abcx3.

    If we consider the C(3,1) ways of selecting one object (a or b or c) and

    represent it a + b + c which is the coefficient of first power of x = x1.

    Similarly the 3 ways of selecting 2 objects (ab or bc or ca) may be

    representedab+bc+ca,whichisthecoefficientofx2.

    Next, there isonlyonewayofselectingall threeobjects,namelyabc, the

    coefficientofx3. Inthelefthandside,thefactor1+axcanbeconsidered

    asrepresentingsymbolicallythetwowaysofselectingaornot,the1(orx0)

    representingthenonselectionofaandaxrepresentingtheselectionof

    a.Thefactors(1+bx)(1+cx)canberepresentedinsimilarway.

    The product of the three factors (1 + ax)(1 + bx)(1 + cx) indicates the

    selectionornonselectionofalltheobjectsa,bandc.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:83

    Considerthegeneralcaseofnobjectsa1,a2,,anbyexpandinginpowers

    ofx,thepolynomial(1+a1x)(1+a2x)(1+a3x)(1+anx)=1+(a1+a2+

    +an)x+(a1a2+a1a3+)x2+(a1a2a3+)x3++(a1a2an)xn.

    The coefficient of x2 on the right hand side represents the rcombination

    choosenfromnobjectsa1,a2,,an.

    Takinga1=a2=.=an=1weget

    (1+x)n=1+nx+2

    1)n(n - x2+.+xn.

    =C(n,0)+C(n,1)x+C(n,2)x2+.+C(n,n)xn..(i).

    The number of rcombinations is equal to the coefficient of xr in the

    expansionof(1+x)r.Eachexpressionisalsotermedasenumeration.

    If theobject isallowedunlimitedrepetitionthenthecorrespondingfactor in

    theenumerationmusthaveeverypowerofxpresentandsois(1+x+x2+

    +xi+)=(1x)1. Thustheenumerationofrcombinationsofnobjects

    withunlimitedrepetitionis(1x)1(1x)1.(1x)1=(1x)n

    =1+nx+2!

    1)n(n + x2+

    3!2)1)(nn(n + +

    x3++r!

    1)r1).....(nn(n + + x2+..

    =

    =

    - +

    0r

    rxr

    1rn.

    The coefficient of xr in (1x)n is C(n + r 1, r) which is the number of

    rcombinationswithunlimitedrepetition.

    Intheexpression(i),replaceC(n,r)byr!

    r)p(n,.

    (1+x)n=1+1!

    1)p(n,x+

    2!2)p(n,

    x2++r!

    r)p(n,xr++

    n!n)p(n,

    xn,here

    p(n,r)isthecoefficientofr!xr .

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:84

    Theexpressiona0+a1 1!x +a2 2!

    x2 +.+ai i!xi +.

    =

    =0i

    i

    i i!xa ,iscalledtheexponentialgeneratingfunction,herear=p(n,r).

    Intheenumerationforrpermutationsofnobjectswithunlimitedrepetition,

    the factor for eachobjectmust represent the fact that theobjectmaynot

    appearorappearonce,twice,,etc.

    Thus each factor is (1 +1!x +

    2!x2 +

    3!x3 +. +

    i!xi + .) and the

    exponentialenumeratoris(1+1!x +

    2!x2 +)n=enx=

    =0r

    ir

    i!xn .

    3.3.1Example

    Howmanycombinationsofthreeobjectscanbeformedifoneobjectcanbe

    selectedatmostonce,thesecondobjectatmosttwiceandthethirdatmost

    threetimes.

    Solution:Thefirstobjectcanappeareitheronceornotatall,sothefactor

    in theenumeratormustcontainx0 andx1 butnootherterms. Thesecond

    objectwillhavex2,xandx0.Similarlythefactorforthethirdobjectwillhave

    x0,x1,x2,x3.

    Thereforetheenumerationis

    (1+x)(1+x+x2)(1+x+x2+x3)=1+3x+5x2+6x3+5x4+3x5+x6.

    Thecoefficientofxarea,b,c

    Thecoefficientofx2areab,ac,bb,bc,cc

    Thecoefficientofx3areabc,abb,acc,bbc,bcc,ccc

    Thecoefficientofx4areabbc,accc,abcc,bbcc,bccc

    Thecoefficientofx5areabbcc,abccc,bbccc

    Thecoefficientofx6areabbccc.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:85

    3.4Partitions,compositions

    Representationofanypositiveintegernasasumofoneormorepositive

    integers(ai)thatis.,n=a1 +a2 +.+am. Notethatthisrepresentationis

    unordereddivisions(senseofcombination)iscalledpartition,whereasthe

    ordereddivision(senseofpermutation)iscalledcomposition.

    3.4.1Example

    Thepartitionsandcompositionsoftheinteger5.

    i) Thereare7unrestrictedpartitions5,4+1,3+2,3+1+1,2+2+1,

    2 + 1 + 1 +1, 1 + 1+ 1 + 1 + 1 and two of these namely,

    4+1and3+2haveexactlytwoparts.

    ii) Thereare 16 unrestricted compositionsof n=5are 5,4+1, 1+4,

    3+2,2+3,3+1+1,1+3+1,1+1+3,2+2+1,2+1+2,

    1+2+2,2+1+1+1,1+2+1+1,1+1+2+1,1+1+1+2,

    1+1+1+1+1andfourofthesehaveexactlytwoparts.

    Some times we omit the sign + in representation of partition or

    composition.Thatis2+1+1+1willbe2111or213.

    3.4.2GeneratingFunctionforpartition

    Letpn be thenumberof unrestrictedpartitionsof nso that thegenerating

    functionisp(x)=p0+p1x+p2x2+.+pnxn+

    Consider the polynomial 1 + x + x2 + x3 + . + xk + . + xn. The

    appearance of xk can be interpreted as the existence of just k ones in a

    partitionoftheintegern.

    Similarlythepolynomial1+x2+x4+.+x2k+.isinterpretedastwosin

    the partition and in particular, the coefficient of x2k = (x2)k represents the

    casejustktwosinthepartition.

    Ingeneral,1+xr+x2r+.+xkr+.representsrsinthepartition.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:86

    Thereforegeneratingfunctionforpartitionsofnisobtainedby

    p(x)=(1+x+x2+.+xk+.)(1+x2+x4+.+x2k+.)

    (1+xr+x2r+.+xkr.).

    =(1x)1(1x2)1.(1xr)1.

    Theenumerationforpartitioninwhichnotermofapartisgreaterthankis

    (1x)1(1x2)1.(1xk)1(i)

    Theenumerationforpartitionwherenotermofapartisgreaterthank1is

    (1x)1(1x2)1.(1xk1)1(ii).

    Subtracting(ii)from(i)givesthegeneratingfunctionforpartitionofnintok

    parts,which isxk(1x)1(1x2)1 .(1xk)1. Thecoefficientofxn gives

    numberofpartitionsofnintoexactlykparts.

    Thepartitionwitheverypartoddareenumeratedbythegeneratingfunction

    containingonlyfactorscorrespondingtooddnumber,1,3,5,is

    (1 x)1(1 x3)1(1 x5)1 Thepartitionwithunequal terms in apart is

    enumeratingbythegeneratingfunction:

    (1+x)(1+x2)(1+x3)

    Each factor can only contain two terms, one which indicates that the

    correspondingnumberdoesnotappearinthepartitionandtheotherthatthe

    numberappearsonce.

    3.4.3 Prove that the number of partitions of n inwhich no integer occurs

    morethantwiceasapartisequaltothenumberofpartitionsofnintoparts

    notdivisibleby3.

    Solution: The generating function corresponding to no integer occurs

    morethantwiceis(1+x+x2)(1+x2+x4)(1+x3+x6) (1)

    Thegeneratingfunctioncorrespondingtonopartisdivisibleby3is

    (1x)1(1x2)1(1x4)1(1x5)1(1x7)1(1x8)1. (2)

    1x3=(1x)(1+x+x2)

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:87

    Therefore(1)becomes

    (1x3)(1x)1(1x6)(1x2)1(1x9)(1x3)1(1x12)(1x4)1(1x15) (1x5)1(1x18)(1x6)1

    =(1x)1(1x2)1(1x4)4(1x5)1(1x7)1,whichisequation(2).

    For instance, taken=6. Thepartitions inwhichno integeroccursmore

    thantwiceare6,51,42,411,33,321,221,1(theseare8innumber).

    Thepartitionsinwhichnopartisdivisibleby3are51,42,411,222,2211,

    214,16.

    3.4.4Generatingfunctionforcompositions

    Considertheunrestrictedcompositionsofninwhichnonesinarow.Since

    there is no restriction on the number of parts, wemay or may not put a

    marker in any of the (n1) spaces between the ones in order to form

    groups.Thiscanbedonein2n1ways.

    Ifwerestrictthecompositionstohaveexactlymparts,then(m1)markers

    are needed to form groups and the number of ways of placing (m1)

    markersinthe(n1)spacesbetweentheonesis

    -

    -

    1m

    1n.

    Let us use the generating function to obtain this. Let Cm(x) be the

    enumeration for competitions of n with exactly m parts, where Cm(x) =

    n

    nmnxC and Cmn is the coefficient of x

    n in this series is the number of

    compositionsofnintoexactlymparts.Eachpartofanycompositioncanbe

    one,two,threeoranygreaternumbersothatthefactorintheenumeration

    mustcontaineachofthesepowersofx,andsois x+x2+x3+x4+.+xk

    +. =x(1+x+x2+.+xk1+xk+.)=x(1x)1.

    Sincethereareexactlymparts,thegeneratingfunctionistheproductofm

    suchfactorsCm(x)=(x+x2+x3+x4+.+xk+.)m

    =xm(1x)m

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:88

    =xm

    =

    - +

    0i

    ixi

    1im.

    Replacingm+ibyr inthesummationweget

    Cm(x)=

    =

    - -

    mr

    rxmr

    1r=

    =

    - -

    mr

    rx1m

    1r.

    Thereforethecoefficientofxn inthisenumerationis

    -

    -

    1m

    1n.

    The generating the compositions with no restriction, C(x) =

    =1mm(x)C =

    =

    - 1m

    mm x)(1x .Taket=x1

    x -

    intheseries,weobtain

    C(x)=t+t2+t3+=t1

    t -

    =2x1

    x -

    =

    =

    -

    1n

    n1n x2 .

    Thecoefficientofxn intheenumerationis2n1.

    3.4.5FerrersGraph

    The representationof permutationsbyanarrayof dots knownas Ferrers

    graph.

    Forinstance,theferrersgraphforthepartition:5322(whichisinstandard

    formwiththelargestpartfirst)is

    o

    o

    oo

    o oooo

    oo

    oo

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:89

    A Ferrersgraphhasthefollowingproperties:

    i) Thereisonerowforeachpart

    ii) Thenumberofdotsinarowisthesizeofthatpart

    iii) Anupperrowalwayscontainatleastasmanydotsasalowerrow

    iv) Therowsarealignedontheleft.

    ThepartitionobtainedbyreadingtheFerrersgraphbycolumnsiscalledthe

    Ferrersconjugatepartition.

    In the above illustration, the same by rows and by columns is called self

    conjugate.Thepartition4321isselfconjugate.

    3.5Orderings

    3.5.1Lexicographicorder

    Let {1, 2, 3,..., n} be n objects to be permuted. For two permutations

    a1,a2,,anandb1,b2,...,bn,wesaythata1,a2,...,ancomesbeforeb1,b2,

    .,bn intheLexicographicorderifforsome1 m

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:90

    3.5.4Problem

    ObtaintheproceduretofindnextpermutationinLexicographicorder.

    Solution:Considerapermutationk1,k2,...,knofndigits.Toobtainthenext

    permutationinLexicographicorder,weproceedasfollows:

    Step(i):Findthelargestisuchthatki1

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:91

    3.5.7Example

    Findthenextpermutationto4123inthereverseLexicographicorder.

    Solution:Considertheorderk1 k2 k3 k4

    4 1 2 3

    i) i=2,sothat1=k2

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:92

    3.6.3Example

    Thirtycarswereassembledinafactory.Theoptionsavailablewerearadio,

    anairconditioner,andwhitewalltires. It isknownthat15ofthecarshave

    radios,8ofthemhaveairconditioners,and6ofthemhavewhitewalltires.

    Moreover,3ofthemhaveallthreeoptions.Findoutatleasthowmanycars

    donothaveanyoptionsatall.

    Sollution:LetA1,A2andA3denotethesetsofcarswiththegivenoptions

    respectively.

    |A1|=15,|A2|=8,|A3|=6,|A1 A2 A3|=3.

    Nowbytheprincipleofinclusionandexclusion,|A1 A2 A3|=15+8+6

    |A1 A2| |A1 A3||A2 A3|+3=32|A1 A2||A1 A3||A2 A3|

    32333=23.

    (hereweusedthefact:|Ai Aj Ak| |Ai Aj|foranyi,j,k)

    Thereforethereareatmost23carshaveoneormoreoptions.Thismeans

    thereareatleast7carsthatdonothaveanyoptions.

    3.6.4Example

    Determinethenumberofintegersbetween1to250thataredivisiblebyany

    oftheintegers2,3,5and7.

    Solution:WriteA1={x Z+ /x 250andxisdivisibleby2}

    SimilarlyA2,A3,A4 aresetof integers 250 thataredivisibleby3,5and

    7respectively.

    |A1|=

    2250

    =125where x denotestheintegersmallerthanorequaltox.

    |A2|=

    3250

    =83,|A3|=

    5250

    =50,|A4|=

    7250

    =35,

    |A1 A2| =

    32250

    =41,|A1 A3|=

    52250

    =25,|A1 A4|=17,|A2 A3|

    =16,|A2 A4|=11,|A3 A4|=7,|A1 A2 A3|=

    532250

    =8,

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:93

    |A1 A2 A4|=5,|A1 A3 A4|=3,|A2 A3 A4|=2,|A1 A2 A3 A4|=1.

    Therefore|A1 A2 A3 A4|=125+83+50+3541251716

    117+8+5+3+21=193.

    3.6.5Example:

    Howmanyarrangementsof thedigits0,1,2,3,4,5,6,7,8,9containat

    leastoneofthepatterns289,234or487?

    Solution: Let A289 be theevent of havingpattern 289. Similarly A234 and

    A487.Wehavetofind|A289orA234orA487|.

    Now|A289|=8!,as289consideredasagroupwhichisasingleobjectand

    theremainingsevensingledigits.Similarly|A234|=|A487|=8!

    Alsosince2cannotbefollowedbyboth3and8,wehave|A289 A234|=0.

    Similarly |A289 A487|=0. But |A234 orA487|=6! ,since23487asasingle

    objectandremaining5singleobjects. |A289 A234 A487|=0.

    Thereforebytheprincipleofinclusionandexclusion

    |A289 A234 A487|=8! +8! +8! 006! +0=3 8! 6! .

    3.6.6Note

    Among the permutations of {1, 2, 3, ., n}, there are some (called

    derangements),inwhichnoneofthenintegersappearsinitsnaturalplace.

    Inotherwords:(i1,i2,,in)isaderangementifi11,i22,.,and inn.

    IfDndenotethenumberofderangementsof{1,2,3,.,n},thenforn=1,

    2,3,wehave, D1 =0,D2 =1,D3 =2 (that is, theonlyderangementsof

    (1,2,3)are(2,3,1)and(3,1,2)).

    3.6.7 TheformulaforDn foranypositiveintegern,

    LetUbethesetofn!Permutationsof{1,2,3,,n}.

    Foreachi,letAi bethepermutation(b1,b2,.,bn)of{1,2,3,.,n}such

    thatbi=i.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:94

    ThenA1={(1,b2,,bn)/(b2,b3,.bn)isapermutationof{2,3,,n}}.

    Therefore|A1|=(n1)!.Inasimilarway|Ai|=(n1)!foreachi.

    Also A1 A2 = {(1, 2, b3, , bn) / (b3, b4, , bn) is a permutation of

    {3,4,,n}}.Therefore|A1 A2|=(n2)!.

    Inasimilarway, |Ai Aj|=(n2)!forall i, j. Thereforeforanyintegerk,

    1 k n.

    |A1 A2 . Ak|=(nk)!.

    Thisistrueforanykcombinationof{1,2,.,n}.

    ThereforeDn= n21 A....AA = ( ) n21 A....AA =|U||A1 A2 . An|

    = n!C(n,1)(n1)!+C(n,2)(n2)!+.+(1)nC(n,n)

    =n!!1!n +

    !2!n

    !3!n +.+(1)n

    !n!n

    =n!

    - + + - + - !n)1(....

    !31

    !21

    !111

    n=n!e1,ifn isverylarge.

    3.6.8Example

    Letnbooksbedistributedtonstudents.Supposethatthebooksarereturned

    anddistributedtothestudentsagainlateron.Inhowmanywayscanthebooks

    bedistributedsothatnostudentwillgetthesamebooktwice?

    Solution:Firsttimethebooksaredistributedinn!wayssincenostudents

    getsthesamebookthathegotfirsttime,thesecondtimeDnways.

    Thereforethetotalnumberofways:

    n!Dn=n!n!

    - + + - + -

    !n1)1(....

    !31

    !21

    !111 n =(n!)2

    - + + - + -

    !n1)1(....

    !31

    !21

    !111 n .

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:95

    3.6.9Example:

    Find the number of derangements of the integers from 1 to 10 inclusive,

    satisfyingtheconditionthatthesetofelementsinthefirst5placesis

    (i) 1,2,3,4,5insomeorder

    (ii) 6,7,8,9,10insomeorder.

    Solution:

    (i).D5.D5ways

    (ii)(5!)2=14,400derangements.

    3.6.10Problem

    Obtain the Euler f function, f(n), the number of integers x such that

    1 x

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:96

    SelfAssessmentQuestions1. InhowmanywayscanthelettersofthewordSUNDAYbearranged?

    HowmanyofthembeginwithSandendwithY?HowmanyofthemdonotbeginwithSbutendwith?

    2. Howmanysolutionsdoes theequation: x+ y + z=17have,wherex,y,zarenonnegativeintegers?

    3. Astudentwishestotakeacombinationofthreecourses,onefromeachof three Science subjects. There are 4 Physics, 3 Chemistry and 2Biologycoursesonoffer.Howmanypossiblecombinationsarethere?

    4. Howmanydifferent twodigitpositive integerscanbeformedfromthedigits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. (i)When repetition is not allowed,

    (ii)Whenrepetitionisallowed.5. Howmany4digitnumberscanbeformedbyusing2,4,6,8when

    repetitionofdigitsisallowed?6. Inhowmanywayscan 4 prizesbedistributedamong 5 personswhen

    i) Nopersongetsmorethan1prizeii) Apersonmaygetanynumberofprizes.iii) Apersongetsalltheprizes.

    7. Out of 15 boys and 9 girls, how many different committees can beformedeachconsistingof6boysand4girls?

    8. Howmanycardsmustyoupickupfromastandard52carddecktobesureofgettingatleastoneredcard.

    9. Show that thenumberof n isequal to thenumberof partitionsof 2nwhichhaveexactlynparts.

    10. Howmanywayscananexaminerassign30marks to8questionssothatnoquestionreceiveslessthan2marks.

    3.7Summary

    The unit provides the close connection between combinatorics and

    computer science for the advantage of both the areas. Computer science

    gainsfromcombinatoricsthe toolsnecessaryforanalyzingalgorithmsand

    data structures. Computer science also benefits from the computational

    problemssuggestedbytheclassicalstructuresofcombinatorics.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:97

    3.8TerminalQuestions

    1. Find thenumberofwayscanweobtainchangeforRs.10 in termsofRs.5,Rs.2 andRs.1.

    2. How many positive integers less than or equal to 70, are relativelyprimeto70?

    3. Howmany ndigit ternary (0, 1, 2) sequences are therewith at leastone0,atleastone1,andatleastone2?

    4. Suppose there are 100 students in a school and there are 40students taking each language, French, 40 taking Latin, 40 takingGerman,20studentsaretakinganygivenpairoflanguages,and10studentsaretakingallthreelanguages,thenhowmanystudentsaretakingnolanguage?

    5. Howmanyarrangementsofsix 0s,five 1s andfour 2s arethereinwhich:i)Thefirst0precedesthefirst1?ii)Thefirst0precedesthefirst1,whichprecedesthefirst2?

    3.9Answers

    SelfAssessmentQuestions

    1. ThewordSUNDAYconsistsof6 letters,whichcanbearranged inP

    (6,6)=6!=720ways. If SoccupiesfirstplaceandYoccupies last

    place, thenother four lettersU, N, D, A can be arranged in 4! =24

    ways. IfSdoesnotoccupythefirstplacebutYoccupies lastplace,

    thefirstplacecanbeoccupiedin4waysbyanyoneofU,N,D,A.For

    thesecondplace, again4 lettersareavailable, includingS. The3rd,

    4th and5th places canbe filledby3, 2, 1ways. Hence the required

    numberofarrangements=4 4 3 2 1=96.

    2. To find the number of elements in {(x, y, z) / x + y + z = 17}= C

    (17+31,17)=C(19,2)=171.

    3. 24.

    4. (i)90,(ii)100.

    5. Thenumberof4digitsnumbersformedis:256.

    6. (i)10,(ii)625.,(iii)620.

    7. 630630.

  • DiscreteMathematics Unit3

    SikkimManipalUniversity PageNo:98

    8. 27cards.9. TaketheFerrersgraphforapartitionofnandacolumnofndots Con

    theleftwegetaFerrersgraphcorrespondingto2nhavingnparts.

    Forinstance,n=4andapartitionforitas:211

    Ferrersgraphis

    Addacolumnofn=4dotstotheleftofthegraphweget

    Thecorrespondingpartitionis3221whichhasn=4partsof2n=8.10. Hereeachpartisgreaterthanorequalto2.Alsogivenn=30,m=8.

    Apartcanberepresentedasx2 +x3 +=x2 [1+x+x2 +]=x2

    (1x)1.Sincethereare8partswehavex16 (1x)8=x16

    =

    - +

    0i

    ixi

    1im= +

    - + 16ixi

    1im

    Sincen=30,thecoefficientofx30 is(herei=14)

    - +

    14

    1148=

    14

    21.

    TerminalQuestions1. 10ways.2. 24.3. The number of n digit ternary (0, 1, 2) sequences are there with

    at least one 0, at least one 1, and at least one 2 is =

    3n3 2n+3.4. HereN=100,N(F)=N(L)=N(G)=40,N(FL)=N(LG)=N(FG)=

    20 andN(FLG)=10.Therefore thenumberof students takingno

    languageis N ( )GLF =100(40+40+40)+(20+20+20) 10=30.5. i)ThenumberofarrangementsisC(15,4) C(10,5).

    ii) C(14,5) C(8,4)ways.

    oo o

    oo o o

    o

    o

    o

    o

    o