130 likes | 257 Views
Discrete Mathematics CS 2610. October 28, 2008. Counting. Part of combinatorics , the study of arrangements of objects. (Sets, sequences, sebsets, etc.) Counting relies on two important, but simple principles: the Product Rule and Sum Rule. Counting. Product Rule
E N D
Discrete Mathematics CS 2610 October 28, 2008
Counting • Part of combinatorics, the study of arrangements of objects. (Sets, sequences, sebsets, etc.) • Counting relies on two important, but simple principles: the Product Rule and Sum Rule
Counting • Product Rule • If a procedure can be broken down into a sequence of I distinct tasks and there are n1 ways to accomplish the first, n2 ways to accomplish the second, etc., then there are n1 n2 … nI ways to accomplish the entire procedure. • Examples: • How many ways to select a 4-digit pass code? • 10 choices for each digit: 10 10 10 10 = 10,000 • How many license plate cominbations with 3 letters followed by 3 numbers? • 26 26 26 10 10 10 = 17,576,000
Counting • Sum Rule • If a procedure can be broken down into a choice of one of I distinct, exhaustive tasks and there are n1 ways to accomplish the first, n2 ways to accomplish the second, etc., then there are n1 + n2 + … + nI ways to accomplish the procedure. • Examples: • How many subsets of a set of size 3? • Let si be the number of subsets of size I • So the answer is s0 + s1 + s2 + s3 = 1 + 3 + 3 + 1 = 8 • (You can derive each si with the product rule.)
Counting • Some problems are straightforward applications of one of these rules. Some problems involve using both rules. • Example: How many 6-8 character passwords containing at least one digit?
Counting • Note that sometimes we will not be able to make our subtasks completely distinct. Some ways of solving a problem might fall into multiple subtasks. • This leads to the Subtraction Principle. • Before introducing this principle, let’s consider the set versions of the Product and Sum Rules. • If A and B are sets, then |A B| = |A| |B| • If A and B are disjoint sets, then |A B| = |A| + |B|
Counting • Subtraction Principle: When using the sum rule, if the subtasks are not distinct, the number of common elements must be subtracted from the sum. • If A and B are sets, then |A B| = |A| + |B| - |A B| • Don’t double count!!! • Example: How many bit strings of length 8 begin with 1 or end with 00? • 27 + 26 - 25 = 128 + 64 -32 = 160.
Counting • In some complex counting problems, decision trees will be useful. This is most common when the number of steps necessary depends on the choices made. • Example: How many ways are there to have a best-of-3 tournament between two cribbage players?
The Pigeonhole Principle • For kZ+, if k+1 or more objects are placed into k slots, there is at least one slot containing two or more objects. • Generalized!!!! • If N objects are placed into k slots, then there is at least one slot containing at least N/k objects.
The Pigeonhole Principle • Examples: • Among 100 people, at least how many must have been born in the same month? • How many 3-digit area codes are necessary to guarantee unique 10-digit phone numbers for a state with 25 million residents?
Permutations and Combinations • A permutation of a set of distinct objects is an ordered arrangement (list) of these objects. • An r-permutation of a set of distinct objects is an ordered arrangement of a subset of size r. • The number of r-permutations of a set with n elements is given by the product rule P(n,r) = n (n-1) … (n-r+1), or P(n,r) = n! / (n-r)!, for 0 ≤ r ≤ n • Example: How many ways to award medals in a race with 8 people?
Permutations and Combinations • An r-combination of a set of distinct objects is an unordered arrangement (subset) of size r. • The number of r-combinations of a set with n elements is given by C(n,r) = n! / [r! (n-r)!], for 0 ≤ r ≤ n • The binomial coefficient symbolism is also used. (More on that later!) • Examples: • How many 5 card poker hands are there? • How many bitstrings of length six contain exactly three 0’s?
Permutations and Combinations • Interesting fact about combinations: • for 0 ≤ r ≤ n, C(n,r) = C(n,n-r) • Why? Because when you select a subset, you actually select two subsets at once- those that are chosen and those that aren’t! • Another example: • How many ways to select a 22-person All-SEC football team consisting of 11 UGA starters and 1 starter from every other SEC team?