discrete structures chapter 4 counting and probability nurul amelina nasharuddin multimedia...

28
Discrete Structures Chapter 4 Counting and Probability Nurul Amelina Nasharuddin Multimedia Department

Post on 19-Dec-2015

226 views

Category:

Documents


2 download

TRANSCRIPT

Discrete StructuresChapter 4

Counting and ProbabilityNurul Amelina Nasharuddin

Multimedia Department

Outline

• Rules of Sum and Product• Permutations• Combinations: The Binomial Theorem• Combinations with Repetition: Distribution• Probability

2

Counting and Probability

• Coin tossing• Different PINs number• Rolling pair of dice – possible outcomes

3

Possibility Trees

• Teams A and B are to play each other repeatedly until one wins two games in a row or a total three games– What is the probability that five games will be

needed to determine the winner?

• Suppose there are 4 I/O units and 3 CPUs. In how many ways can I/Os and CPUs be attached to each other when there are no restrictions?

4

Multiplication Rule(Rule of Product)

• Multiplication rule: If an operation consists of k steps each of which can be performed in ni ways (i = 1, 2, …, k), then the entire operation can be performed in ni ways

• Assume: If an operation consists of k steps and– The step 1 can be performed in n1 ways– The step 2 can be performed in n2 ways– The step k can be performed in nk ways

Then the entire operation can be performed in n1n2…nk ways

5

Multiplication Rule(Rule of Product)

6

Example (1)

• Suppose a computer installation has 4 I/O unit (A,B,C,D) and 3 CPU (X,Y,Z)

• Any I/O can be paired with any CPU• How many ways to pair an I/O with a CPU• Pairing the two types of units as a two-step

operation:– Step 1: Choose the I/O unit– Step 2: Choose the CPU unit

There are 12 ways (e.g AX, AY, AZ,…)

7

Example (2)

• The drama club of Central University is holding tryouts for a spring play

• With six men and eight women auditioning for the leading male and female roles, by the rule of product the director can cast his leading couple in 6 x 8 = 48 ways

8

Example (3)

• Consider the manufacture of license plates consisting of 2 letters followed by 4 digits. (e.g. AM1234)

• If no letter or digit can be repeated, there are 26 x 25 x 10 x 9 x 8 x 7 = 3,276,000

different possible plates• With repetitions of letters and digits,

26 x 26 x 10 x 10 x 10 x 10 = 6,760,000different plates are possible

• If repetitions are allowed, as in part (b), how many of the plates have only vowels (A,E,I,O,U) and even digits? (0 is an even integer)

9

Example (4)

• Three officers – a president, a treasurer and a secretary are to be chosen from four people: Alice, Bob, Cindy and Dan. Alice cannot be a president, either Cindy or Dan must be a secretary. How many ways can the officers be chosen?

• Construct the possibility tree!10

Addition Rule(Rule of Sum)

• Addition rule: If a finite set A is a union of k mutually disjoint sets A1, A2, …, Ak, then n(A) = n(Ai)

• Assume:– Task 1 can be performed in m ways– Task 2 can be performed in n ways– And the two tasks cannot be performed

simultaneously

Then performing either task can be accomplished in any one of m + n ways

11

Addition Rule(Rule of Sum)

• More formally, the rule of sum is a fact about set theory

• It states that sum of the sizes of a finite collection of pairwise disjoint sets is the size of the union of these sets

• That is, if A1, A2,..., An are pairwise disjoint sets, then

we have:

|A1|+|A2| + … +|An| = |A1 A2 … An|

• n(A) = n(A1) + n(A2) + n(A3) + … + n(Ak)12

Example (1)

• A college library has 40 textbooks on Databases and 50 textbooks dealing with Calculus• By the rule of sum, a student can select among 40 + 50 = 90

textbooks to learn more about one or the other of these two languages

13

Example (2)

• A computer science instructor has 7 different introductory books each on C++, Java, and Perl

• He can recommend any one of these 21 books to a student who is interested in learning a first programming language

14

Example (3)• A lady has decided to shop at one store today,

either in the north part of PJ or the south part of PJ

• If she visits the north part of PJ, she will either shop at a mall, a furniture store, or a jewelry store (3 ways)

• If she visits the south part of PJ then she will either shop at a clothing store or a shoe store (2 ways)

• Thus there are 3+2=5 possible shops the woman could end up shopping at today

15

Summary: Multiplication and Addition Rules

Multiplication Rule: Assuming a) We need to perform procedure 1 AND procedure 2b) There are n1 ways to perform procedure 1 andc) n2 ways to perform procedure 2

There are n1• n2 ways to perform procedure 1 AND procedure 2

Addition Rule: Assuming a) We need to perform procedure 1 OR procedure 2

b) There are n1 ways to perform procedure 1 and

c) n2 ways to perform procedure 2

There are n1+ n2 ways to perform procedure 1 OR procedure 2

This “OR” is an “exclusive OR.” One choice or the other, but not both16

Exercises

17

1. You are taking a test that has five True/False questions. If you answer each question with True or False and leave none of them blank, in how many ways can you answer the whole test?

2. A company places a 6-symbol code on each unit of product.  The code consists of 4 digits, the first of which is the number 5, followed by 2 letters, the first of which is NOT a vowel.  How many different codes are possible? (Repetition is allowed)

3. There is one position available for a faculty job at UPM. The applicant must come from either FK which has 20 candidates or FSKTM which has 50 candidates. What is the total number of possible candidates for the position?

Send in the answers!

Permutations

• Continuing to examine applications of the rule of product, we turn now to counting linear arrangements of objects

• These arrangements are often called permutation when the objects are distinct

• Note: order is taken into account

18

Permutations

• A permutation of a set of distinct objects is an ordered arrangement these objects

• The number of linear permutations of a set of N objects = N!- N possible for 1st position (N-1) for 2nd … (1) for last

• The number of circular permutations of N objects = (N -1)!

– Fix one person, – Then (N-1) possible for next position (N-2) for 2nd …

(1) for last

19

Example (1)

• How many ways can the letter in the word COMPUTER be arranged in a row?

• All the letters in the word COMPUTER are distinct, so

• 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 1st 2nd 3rd 4th 5th 6th 7th 8th

= 8! = 40,320 arrangements.

20

Example (2)

• 6 people sit in a row with exactly 6 seats. How many ways can they be seated together in the row?

• 6 x 5 x 4 x 3 x 2 x 1 1st 2nd 3rd 4th 5th 6th

= 6! = 720 arrangements.

21

Permutations

• If there are n elements in a set, and you want to line-up (arrange) only r of them: r-permutation

• The number of r-permutations of a set with n elements is denoted by P(n, r)

• P(n, r) = n(n – 1)(n – 2) … (n – r +1)= n! / (n – r)!

• *Show that P(n, 2) + P(n, 1) = n2

22

Permutations

• P(n, r) counts (linear) arrangements in which the objects cannot be repeated

• However, if repetitions are allowed, then by the rule of product there are nr possible arrangements with r ≥ 0

23

Permutations

• Permutations of n objects in which n1 are of one

kind, n2 are of a second kind, ... nk

are of a k‐th kind, where n1 + n2 + ... + nk = n, is

• Eg: In how many ways can the six letters of the word “mammal” be arranged in a row?

Since there are 3 “m”s, 2 “a”s and 1 “l” in the word “mammal”, we have:

24

!!...!!

!

321 knnnn

n

60!1!2!3

!6

Example (1)

• In a class of 10 students, five are to be chosen and seated in a row for a picture. How many such linear arrangements are possible?

• 10 x 9 x 8 x 7 x 6 1st 2nd 3rd 4th 5th

= 10!/5! = 30,240 arrangements.

25

Example (2)

• The number of permutations of the letters in the word COMPUTER is 8!

• If only four of the letters are used, the number of permutations (of size 4) or 4-permutations is P(8, 4) = 8! = 8!

(8 - 4)! 4! = 1680

26

Example (3)

• Unlike example before, the number of (linear) arrangements of the four letters in BALL is 12, not 4! or 24.

• If the two L’s are distinguished as L1, L2, then we can use our previous ideas; with the four distinct symbols B, A, L1, L2, we have 4! = 24 permutations, includingA B L1 L2 and A B L2 L1 and others

27

12!1!1!2

!4

Example (4)

• The MASSASAUGA is a brown and white venomous snake. • Arranging all of the letters in MASSASAUGA, we find that

there are arrangements.

• Arrangements in which all four A’s are together are 7! = 840 3! 1! 1! 1! 1!

• To get this last result, we considered all arrangements of the seven symbols AAAA (one symbol), S, S, S, M, U, G.

28

200,25!1!1!1!3!4

!10