Counting
CS 30 : Discrete Mathematics for Computer Science First Semester, AY 2012-2013
https://sites.google.com/a/dcs.upd.edu.ph/nhsh_classes/cs 30
sablay-logo
Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University of the Philippines, Diliman nshernandez@dcs.upd.edu.ph updilseal
Day 10
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Combinatorics and Computing
sablay-logo
1
Counting Permutations Combinations
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
In how many ways can we select three students from a group of ve students to stand in line for a picture?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
In how many ways can we select three students from a group of ve students to stand in line for a picture?
sablay-logo
In how many ways can we arrange all ve of these students in a line for a picture?
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
De nition A permutation of a set of distinct objects is an ordered arrangement of these objects.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
De nition A permutation of a set of distinct objects is an ordered arrangement of these objects. An ordered arrangement of r elements of a set is called an r -permutation.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S :
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S :
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2 2,3
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2 2,3 3,1
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2 2,3 3,1 1,3
Discrete Mathematics for Computer Science
sablay-logo
updilseal
dcs-logo
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2 2,3 3,1 1,3 2,1 Discrete Mathematics for Computer Science
sablay-logo
updilseal
dcs-logo
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3}. Permutations of S : 1,2,3 2,3,1 3,1,2 1,3,2 2,1,3 3,2,1 2-permutations of S : 1,2 2,3 3,1 1,3 2,1 3,2 Discrete Mathematics for Computer Science
sablay-logo
updilseal
dcs-logo
CS 30
acl-logo
Counting
Permutations Combinations
A formula for P (n, r ) The number of r -permutations of a set with n elements is denoted by P (n , r ).
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
A formula for P (n, r ) The number of r -permutations of a set with n elements is denoted by P (n , r ). Theorem If n is a positive integer and r is an integer with
1 ≤ r ≤ n, then there are
sablay-logo
( , ) = n(n − 1)(n − 2) · · · (n − r + 1)
P n r
r -permutations of a set with n distinct elements.
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
A formula for P (n, r ) The number of r -permutations of a set with n elements is denoted by P (n , r ). Theorem If n is a positive integer and r is an integer with
1 ≤ r ≤ n, then there are
sablay-logo
( , ) = n(n − 1)(n − 2) · · · (n − r + 1)
P n r
r -permutations of a set with n distinct elements.
Corollary If n is a positive integer and r is an integer with 0 ≤ r ≤ n, then updilseal
! P (n , r ) = (n − r )! n
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example How many ways are there to select a rst-prize winner, a second-prize winner, and a third-prize winner from 100 di erent people who have entered a contest? 1
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example How many ways are there to select a rst-prize winner, a second-prize winner, and a third-prize winner from 100 di erent people who have entered a contest? 1
2
Suppose that there are eight runners in a race. The winner receives a gold medal, the second-place nisher receives a silver medal, and the third-place nisher receives a bronze medal. How many di erent ways are there to award these medals, if all possible outcomes of the race can occur and there are no ties?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example How many ways are there to select a rst-prize winner, a second-prize winner, and a third-prize winner from 100 di erent people who have entered a contest? 1
2
3
Suppose that there are eight runners in a race. The winner receives a gold medal, the second-place nisher receives a silver medal, and the third-place nisher receives a bronze medal. How many di erent ways are there to award these medals, if all possible outcomes of the race can occur and there are no ties? Suppose that a saleswoman has to visit eight di erent cities. She must begin her trip in a speci ed city, but she can visit the other seven cities in any order she wishes. How many possible orders can the saleswoman use when visiting these cities?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example How many ways are there to select a rst-prize winner, a second-prize winner, and a third-prize winner from 100 di erent people who have entered a contest? 1
2
3
4
Suppose that there are eight runners in a race. The winner receives a gold medal, the second-place nisher receives a silver medal, and the third-place nisher receives a bronze medal. How many di erent ways are there to award these medals, if all possible outcomes of the race can occur and there are no ties? Suppose that a saleswoman has to visit eight di erent cities. She must begin her trip in a speci ed city, but she can visit the other seven cities in any order she wishes. How many possible orders can the saleswoman use when visiting these cities? How many permutations of the letters ABCDEFGH contain the string ABC ? Discrete Mathematics for Computer Science
CS 30
sablay-logo
updilseal
dcs-logo
acl-logo
Counting
Permutations Combinations
sablay-logo
How many di erent committees of three students can be formed from a group of four students?
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
De nition An r -combination of elements of a set is an unordered selection of r elements from the set.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
De nition An r -combination of elements of a set is an unordered selection of r elements from the set. Thus, an r -combination is simply a subset of the set with r elements.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}.
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}. 3-combinations from S :
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}. 3-combinations from S : 1,2,3
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}. 3-combinations from S : 1,2,3 1,2,4
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}. 3-combinations from S : 1,2,3 1,2,4 1,3,4
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
An Example Let S = {1, 2, 3, 4}. 3-combinations from S : 1,2,3 1,2,4 1,3,4 2,3,4
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
A formula for C (n, r ) The number of r -combinations of a set with n distinct elements is n denoted by C (n, r ). It is also denoted by . r
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Permutations Combinations
Counting
A formula for C (n, r ) The number of r -combinations of a set with n distinct elements is n denoted by C (n, r ). It is also denoted by . r
Theorem
sablay-logo
The number of r -combinations of a set with n elements, where n is a nonnegative integer and r is an integer with
( , )=
C n r
r
0 ≤ r ≤ n, equals
n! !(n − r )!
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Permutations Combinations
Counting
A formula for C (n, r ) The number of r -combinations of a set with n distinct elements is n denoted by C (n, r ). It is also denoted by . r
Theorem
sablay-logo
The number of r -combinations of a set with n elements, where n is a nonnegative integer and r is an integer with
( , )=
C n r
r
0 ≤ r ≤ n, equals
n! !(n − r )!
Corollary Let n and r be nonnegative integers with r ≤ n. Then
updilseal
( , ) = C (n, n − r )
C n r
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
How many poker hands of ve cards can be dealt from a standard deck of 52 cards?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
How many poker hands of ve cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
2
How many poker hands of ve cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards? How many ways are there to select ve players from a 10-member tennis team to make a trip to a match at another school?
sablay-logo
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
2
3
How many poker hands of ve cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards? How many ways are there to select ve players from a 10-member tennis team to make a trip to a match at another school?
sablay-logo
A group of 30 people have been trained as astronauts to go on the rst mission to Mars. How many ways are there to select a crew of six people to go on this mission?
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
2
3
4
How many poker hands of ve cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards? How many ways are there to select ve players from a 10-member tennis team to make a trip to a match at another school?
sablay-logo
A group of 30 people have been trained as astronauts to go on the rst mission to Mars. How many ways are there to select a crew of six people to go on this mission? How many bit strings of length n contain exactly r 1s? updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo
Counting
Permutations Combinations
Example 1
2
3
4
5
How many poker hands of ve cards can be dealt from a standard deck of 52 cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards? How many ways are there to select ve players from a 10-member tennis team to make a trip to a match at another school?
sablay-logo
A group of 30 people have been trained as astronauts to go on the rst mission to Mars. How many ways are there to select a crew of six people to go on this mission? How many bit strings of length n contain exactly r 1s? Suppose there are 9 faculty in the mathematics department and 11 in the computer science department. How many ways are there to select a committee to develop a discrete mathematics course at a school if the committee is to consist of three faculty members from the mathematics department and four from the computer science department? Discrete Mathematics for Computer Science
CS 30
updilseal
dcs-logo
acl-logo
Counting
Questions?
sablay-logo
See you next meeting!
updilseal
dcs-logo
Discrete Mathematics for Computer Science
CS 30
acl-logo