64
Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Embed Size (px)

Citation preview

Page 1: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Unit VI Discrete Structures

Permutations and Combinations

SE (Comp.Engg.)

Page 2: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• BOTH

• PERMUTATIONS AND COMBINATIONS

• USE A COUNTING METHOD CALLED

FACTORIAL

Page 3: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Lets start with a simple example.

• A student is to roll a die and flip a coin. How many possible outcomes will there be?

Page 4: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• 1H 2H 3H 4H 5H 6H• 1T 2T 3T 4T 5T 6T

Page 5: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• The number of ways to arrange the letters ABC:

____ ____ ____

Number of choices for first blank? 3 ____ ____

3 2 ___Number of choices for second blank?

Number of choices for third blank? 3 2 1

Page 6: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Permutations

• A Permutation is an arrangement of items in a particular order.

The number of Permutations of n items chosen r at a time, is given by the formula

. 0 where nrrn

nrpn

)!(

!

Page 7: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Arrange 2 alphabets from a,b,c.

• ab, ba, ac,ca,bc,cb

• 3P2=3!/(3-2)!=6

Page 8: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• A combination lock will open when the right choice of three numbers (from 1 to 30, inclusive) is selected. How many different lock combinations are possible assuming no number is repeated?

Page 9: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

2436028*29*30)!330(

!30330

27!

30! p

Page 10: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

CIRCULAR PERMUTATIONS

When items are in a circular format, to find the number of different arrangements, divide:

n! / n

Page 11: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Six students are sitting around a circular table in the cafeteria. How many different seating arrangements are there?

Page 12: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• 6! 6 = 120

Page 13: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Combination

• A Combination is an arrangement of items in which order does not matter.

. 0 where nrrnr

nrCn

)!(!

!

The number of Combinations of n items chosen r at a time, is given by the formula

Page 14: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• To play a particular card game, each player is dealt five cards from a standard deck of 52 cards. How many different hands are possible?

Page 15: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

960,598,21*2*3*4*5

48*49*50*51*52

)!552(!5

!52552

5!47!

52! C

Page 16: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• A student must answer 3 out of 5 essay questions on a test. In how many different ways can the student select the questions?

Page 17: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

101*2

4*5

)!35(!3

!535

3!2!

5! C

Page 18: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Product and Sum Rules

• Product Rule: • If we need to perform procedure 1 AND

procedure 2.There are n1 ways to perform procedure 1 and n2

ways to perform procedure 2.

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

Page 19: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Sum Rule: If need to perform either procedure 1 OR

procedure 2. There are n1 ways to perform

procedure 1 and 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 both.

Page 20: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• How many vehicle number plates can be made if each plate contains two different letters followed by three different digits

Page 21: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Two different letters are made in 26P2 ways.

3 different digits are combined in 10P3ways

Total no. of number plates= 26P2 * 10P3

=26!*10!/(24!*7!)

=26*25*10*9*8

=468000

Page 22: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• An 8 member team is to be formed from a group of 10 men and 15 women. In how many ways can the team be chosen if :

(i) The team must contain 4 men and 4 women(ii) There must be more men than women(iii) There must be at least two men

Page 23: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

The team must contain 4 men and 4 women = 286650

(ii) There must be more men than women = (iii) There must be at least two men

Page 24: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Passwords consist of character strings of 6 to 8 characters. Each character is an upper case letter or a digit. Each password must contain at least one digit.

• How many passwords are possible?

Page 25: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Total number is• # passwords with 6 char. + # passwords

with 7 char. + # pws 8 char.• (=P6+P7+P8).

Page 26: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• P6: # possibilities without constraint : 366

• # exclusions is # passwords without any digits is 266

• And so, P6 = 366-266

Page 27: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• Similarly, P7 = 367-267 and P8 = 368-268

Page 28: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• P = P6+P7+P8 = 366-266 + 367-267 + 368-2

Page 29: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• How many bit-strings of length 8 either begin with 1 or end with 00?

Page 30: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• A = 8-bit strings starting with 1• |A| = # of 8-bit strings starting with 1 is 27

• B = 8-bit strings starting with 00• |B| = # of 8-bit strings ending with 00 is 26

• # of bit-strings begin with 1 and end with 00 is 25.

Page 31: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• # of 8-bit strings starting with 1 or ending with 00 is

• 27+ 26- 25

Page 32: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• |AB| = |A| + |B| - |AB|• Inclusion–Exclusion Principle

Page 33: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

33

Permutations with non-distinguishable objects

• The number of different permutations of n objects, where there are non-distinguishable objects of type 1, non-distinguishable objects of type 2, …, and non-distinguishable objects of type k, is

i.e., C(n, )C(n- , )…C(n- - -…- , )

1 2

!! !... !kn

n n n

1n

2nkn

1n 1n 2n 1n 2n 1kn kn

1 2 ... kn n n n

Page 34: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• How many different strings can be made by reordering the letters of the word

OFF

Page 35: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• 3!/2!=3• OFF• FFO• FOF

Page 36: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• ONE• OEN• NEO• NOE• ENO• EON

Page 37: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• How many different strings can be made by reordering the letters of the word

SUCCESS

Page 38: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Generating Permutations

Lexicographic method

Page 39: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• For the following 4• combinations from the set f= {1;2;3;4;5;6;7}

find the combination that immediately follows them in lexicographic order

1234 is followed by3467 is followed by4567 is followed by

Page 40: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

What is probability?

• Probability is the measure of how likely an event or outcome is.

• Different events have different probabilities!

Page 41: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

How do we describe probability?

• You can describe the probability of an event with the following terms:– certain (the event is definitely going to happen)– likely (the event will probably happen, but not definitely)– unlikely (the event will probably not happen, but it might)– impossible (the event is definitely not going to happen)

Page 42: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• probabilities are expressed as fractions.– The numerator is the number of ways the event

can occur.– The denominator is the number of possible events

that could occur.

Page 43: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

6.43

Random Experiment…• …a random experiment is an action or process

that leads to one of several possible outcomes. For example:

Experiment Outcomes

Flip a coin Heads, Tails

Exam Marks Numbers: 0, 1, 2, ..., 100

Assembly Time t > 0 seconds

Course Grades F, D, C, B, A, A+

Page 44: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

What is the probability that I will choose a red marble?

• In this bag of marbles, there are:– 3 red marbles– 2 white marbles– 1 purple marble– 4 green marbles

Page 45: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Probability example• Sample space: the set of all possible outcomes.

• Probabilities: the likelihood of each of the possible outcomes (always 0 P 1.0).

)(1)(

)(1)(

1)()(

1)(0

EPEP

EPEP

EPEP

EP

Page 46: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

6.46

Probabilities…

• List the outcomes of a random experiment…

• This list must be exhaustive, i.e. ALL possible outcomes included.

• Die roll {1,2,3,4,5} Die roll {1,2,3,4,5,6}

• The list must be mutually exclusive, i.e. no two outcomes can occur at the same time:

• Die roll {odd number or even number} • Die roll{ number less than 4 or even number}

Page 47: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

• A and B are independent if and only if P(A&B)=P(A)*P(B)

• A and B are mutually exclusive events:P(A or B) = P(A) + P(B)

Page 48: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

6.48

Events & Probabilities…

• The probability of an event is the sum of the probabilities of the simple events that constitute the event.

• E.g. (assuming a fair die) S = {1, 2, 3, 4, 5, 6} and• P(1) = P(2) = P(3) = P(4) = P(5) = P(6) = 1/6

• Then:• P(EVEN) = P(2) + P(4) + P(6) = 1/6 + 1/6 + 1/6 = 3/6 =

1/2

Page 49: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Female

Low

Male

e.g. 1. The following table gives data on the type of car, grouped by petrol consumption, owned by 100 people.

42123

73312

HighMedium

One person is selected at random.L is the event “the person owns a low rated car”F is the event “a female is chosen”.

Find (i) P(L) (ii) P(F L) (iii) P(F| L)

100

Total

Page 50: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

(i) P(L) =

Solution:

Find (i) P(L) (ii) P(F L) (iii) P(F L)

100

42123Female

73312Male

HighMediumLow

20 20

7

735

100

(ii) P(F L) =23

Total

100

(iii) P(F L) =23

Notice that

P(L) P(F L)35

23

20

7

100

23

So, P(F L) = P(F|L) P(L)

= P(F L)35

5

1

Page 51: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

45RF

e.g. 2. I have 2 packets of seeds. One contains 20 seeds and although they look the same, 8 will give red flowers and 12 blue. The 2nd packet has 25 seeds of which 15 will be red and 10 blue.

Draw a Venn diagram and use it to illustrate the conditional probability formula.

Solution:

15

10

12

P(R F) =

P(F) =P(R F) = 8

845

208

45

20

20

8

P(R F) = P(R|F) P(F) So,

P(R F) P(F) =

2045

45

8

1

1

Let R be the event “ Red flower ” and F be the event “ First packet ”

Page 52: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Bayes’ Rule: derivation

)(

)&()/(

BP

BAPBAP

• Definition:Let A and B be two events with P(B) 0. The conditional probability of A given B is:

Page 53: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

BAPBPBAPBP

BAPBPABP

|~~|

||

Page 54: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Example

• Three jars contain colored balls as described in the table below.– One jar is chosen at random and a ball is selected. If the ball is red,

what is the probability that it came from the 2nd jar?

Jar # Red White Blue

1 3 4 12 1 2 33 4 3 2

Page 55: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Example

• We will define the following events:– J1 is the event that first jar is chosen

– J2 is the event that second jar is chosen

– J3 is the event that third jar is chosen– R is the event that a red ball is selected

Page 56: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Example

• The events J1 , J2 , and J3 mutually exclusive – Why?

• You can’t chose two different jars at the same time

• Because of this, our sample space has been divided or partitioned along these three events

Page 57: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Venn Diagram

• Let’s look at the Venn Diagram

Page 58: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Venn Diagram

• All of the red balls are in the first, second, and third jar so their set overlaps all three sets of our partition

Page 59: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Finding Probabilities

• What are the probabilities for each of the events in our sample space?

• How do we find them?

BPBAPBAP |

Page 60: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Computing Probabilities

• Similar calculations show:

8

1

3

1

8

3| 111 JPJRPRJP

27

4

3

1

9

4|

18

1

3

1

6

1|

333

222

JPJRPRJP

JPJRPRJP

Page 61: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Venn Diagram

• Updating our Venn Diagram with these probabilities:

Page 62: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Where are we going with this?

• Our original problem was:– One jar is chosen at random and a ball is selected.

If the ball is red, what is the probability that it came from the 2nd jar?

• In terms of the events we’ve defined we want:

RPRJP

RJP

22 |

Page 63: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

Finding our Probability

RJPRJPRJP

RJP

RP

RJPRJP

321

2

22 |

Page 64: Unit VI Discrete Structures Permutations and Combinations SE (Comp.Engg.)

17.071

12

274

181

81

181

|321

22

RJPRJPRJP

RJPRJP