190 likes | 355 Views
COT 3100-01 Introduction to Discrete Structures. Instructor: Nadia Baranova baranova@cs.ucf.edu Office: CCI-216, phone (407) 823-1063 Office hours: M 7p.m.-8p.m., W 2p.m.-3p.m. Combinatorics and counting technique reading: 1.1-1.4 from the textbook. The Rule of Sum
E N D
COT 3100-01 Introduction to Discrete Structures Instructor: Nadia Baranova baranova@cs.ucf.edu Office: CCI-216, phone (407) 823-1063 Office hours: M 7p.m.-8p.m., W 2p.m.-3p.m.
Combinatorics and counting technique reading: 1.1-1.4 from the textbook The Rule of Sum If the first event can occur in m ways, the second event can occur in n ways, two events can not occur simultaneously, then either the first event or the second can occur in m+n ways. Example Suppose for graduation you need to take one course in any programming language. There are 10 courses offered in CS and 5 courses in EE. How many choices do you have? n =10, m =5, n+m = 15
The Rule of Product If something can happen in n ways, and no matter how the first thing happens, a second thing can happen in m ways, then two things together can happen in n·m ways.
00 0 0 01 1 four 2-bit strings 10 0 1 1 11 first second Example Abit (or binary digit) is a zero or one. A bit string is defined to be a sequence of bits. Different symbols can be encoded by bit strings. Suppose we want to encode 26 letters of the English alphabet. Is it sufficient to use one and two bit strings? Here they are: 0, 1, 00, 01, 10, 11- only six different strings.
0 0 0 0 1 1 1 1 How many 3 bit strings exist? 22 2=8 0 0 1 0 1 1 first second third
Example DNA is a chain of 4 bases: T, C, A and G. How long the chain should be to encode one of 20 existing amino acids? Take 2-element DNA chains. How many such chains are there?
T T T T C C C C A A A A G G G G TT TC TA TG T CT CC CA CG C AT AC AA AG A TT TC TA TG G
In general, The Rule of Sum and The Rule of Product should be used in combination. R6 C R4 B R1 R5 R2 R7 R3 A • In how many ways you can travel from A to C? • How many different round trips from A to C and back to A? • How many round trips are at least partially different?
3 4 15 1 2 ... In how many ways 15 different books can be placed on twoshelves so that there is at least one book at each shelf? Any arrangement can be considered as a two-step task. The first step is to make a permutation of 15 books. The second step is to distribute the arrangement between two shelves.
26 25 24= Permutations: arrangements when the order is important. It is often important to count the number of arrangements of n distinct objects (the number of permutations). • How many permutations of 3 letters a, b and c exist? 32 1=3! • How many words of 3 distinct letters can be formed • from 26-letter alphabet? The number of permutations of size r for n distinct objects P(n, r) =
Permutations with repetitions If we can repeatedly take each of n distinct object then the number of possible arrangements is: n n n … n = nr r
Permutations of the objects when some of them are identical Consider permutations of n objects in case when k of these objects are non-distinguishable, 0 < k < n . For example, take permutations of letters from BALL, n = 4, k = 2. The number of permutations is less then 4! We could make it equal to 4! by introducing some way to distinguish two L’s, say L1 and L2. Combine all 4! permutations of letters B, A, L1 and L2 into groups, where arrangements within each group differ by permutations of L1 and L2 only (B and A are at fixed positions). How many arrangements are inside each group?
1. BAL1L2 BAL2L1 2. BL1AL2 BL2AL1 3. BL1L2A BL2L1A 4. ABL1L2 ABL2L1 5. L1BAL2 L2BAL1 6. L1BL2A L2BL1A 7. AL1BL2 AL2BL1 8. L1ABL2 L2ABL1 9. L1L2BA L2L1BA 10. AL1L2BBAL2L1 11. L1AL2BL2AL1B 12. L1L2AB L2L1AB The number of groups is 4!/2!=the number of permutations of 4 objects if 2 of them are identical
In general, the number of permutations of n objects when k of them are not distinguishable is n!/k!. We can look at the same problem in another way. We have n distinct boxes (positions) that should be assigned into n-k distinguishable objects. All the rest will be filled with k identical objects. This is the problem of permutations of size n-k from n distinct objects P(n, n-k)=n!/k!.
More generally: if there are n objects with n1 objects of the first type, n2 objects of the second type, … nrobjects of the r-th type, where n1+n2+…+nr=n, then the number of permutations is n! n1! n2!…nr! • How many permutations of letters A, B, B, C, C, C exist? Let’s again introduce indexes to make letters distinguishable. Then we have 6! different arrangements. Combine them into groups that differ by permutations of C1, C2 and C3. There will be 3! arrangements in every such group. Next we should combine those groups that are differed only by permutations of B1 and B2.
6·5·4 2 1 2 3 4 5 6 6! 3! 3! ... 3! 3! ... 2! 2! distinct arrangements
Permutations ofsize r out of n objects (r < n), when not all n objects are distinct. • This is an example of a problem that should be attacked • by breaking it into simpler cases. • Consider a particular example. How many 3-letter words can be • made from the letters from the word BALL? • First you need to observe that there exist different cases • depending on whether you use one or two L’s. • By the rule of sum you should add three numbers: • permutations of BAL : 3!=6 • permutations of ALL: 3!/2! = 3 • permutations of BLL: 3!/2! = 3 • So, the total number is 6+3+3=12.
Combinations : selections when the order does not matter Suppose we draw 3 cards from a deck of 52 cards. How many different selections (or combinations) exist? Here the order of 3 cards does not matter. By the product rule the number of permutations P(52, 3) is the number of combinations C(52, 3) times the number of permutations of 3 selected cards (i. e. 3!): C(52, 3) 3! = P(52, 3) =52!/(52-3)! C(52, 3) = 52!/(49! 3!) C(n, r)
The Binomial Theorem (x+y)n = (x+y) (x+y)… (x+y) = xn + n xn-1y +C(n, 2) xn-2y2 +… n factors (x+y)n=