230 likes | 487 Views
CS 199: Discrete Math Bonus!. Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 9:30-11:30a. CS 199 Announcements. Nothing yet. . Product Rule. CS 199 Counting.
E N D
CS 199:Discrete Math Bonus! Cinda Heeren heeren@cs.uiuc.edu Siebel Center, rm 2213 Office Hours: W 9:30-11:30a
CS 199 Announcements • Nothing yet. Cs173 - Spring 2004
Product Rule CS 199 Counting Suppose you have 4 shirts, 3 pairs of pants, and 2 pairs of shoes. How many different outfits do you have? Cs173 - Spring 2004
B 64 4 4 4 CS 199 Product Rule How many functions are there from set A to set B? A To define each function we have to make 3 choices, one for each element of A. How many ways can each choice be made? Cs173 - Spring 2004
B 24 2 4 3 CS 199 Product Rule How many one-to-one functions are there from set A to set B? A To define each function we have to make 3 choices, one for each element of A. How many ways can each choice be made? Cs173 - Spring 2004
Sum Rule Be careful not to overcount. CS 199 Counting A locker code is a sequence of 3 letters where the first letter is a consonant, the second letter is a vowel, and the third letter is Z, OR the first letter is a vowel, and the second and third letter together are a state abbreviation. Are there enough locker codes for everyone in this room? Cs173 - Spring 2004
CS 199 Another question for you • Suppose you are planning an evening of Har Bopping, and you want to Bop 4 Hars. If there are 7 Hars on campus, and if you agree that tonight’s game requires that some Har be Bopped more than once, how many different Har Bopping schedules can you make? Ex: AABC, ACCD, AFAF are valid Har Bopping schedules, but AFDE is not. Cs173 - Spring 2004
YUCK! CS 199 From last time? One approach: • First 2 are alike, and last two are different: 7x1x6x5. • First and third alike, second and fourth different: 7x6x1x5. • First two alike, last two alike, different from first: 7x1x6x1. • Etc. Cs173 - Spring 2004
Each entry unique 74 7x6x5x4 74 - 7x6x5x4 = 1561 CS 199 From last time? A better approach: • Count total number of schedules possible: • Subtract those that you don’t want to count: • All others must have repeats. Cs173 - Spring 2004
20 CS 199 Decision Tree How many different best of 5 game series are possible between the Cardinals and the Astros? Cs173 - Spring 2004
CS 199 Ice Cream Cones Do these two cones provide the same ice cream experience? Cs173 - Spring 2004
P(n,r) = n! / (n-r)! • 60 • 125 • 12!/7! • 512 • No clue CS 199 Permutations In a running race of 12 sprinters, each of the top 5 finishers receives a different medal. How many ways are there to award the 5 medals? 11 10 9 8 12 A permutation is an ordered arrangement of objects. The number of permutations of r distinct objects chosen from n distinct objects is denoted P(n,r). Cs173 - Spring 2004
P(17,10) = 17x16x15x14x13x12x11 CS 199 Permutations Suppose you have time to listen to 10 songs on your daily jog around campus. There are 6 Cake tunes, 8 Moby tunes, and 3 Eagles tunes to choose from. How many different jog playlists can you make? Cs173 - Spring 2004
P(6,4) x P(8,4) x P(3,2) CS 199 Permutations Suppose you have time to listen to 10 songs on your daily jog around campus. There are 6 Cake tunes, 8 Moby tunes, and 3 Eagles tunes to choose from. Now suppose you want to listen to 4 Cake, 4 Moby, and 2 Eagles tunes, in that band order. How many playlists can you make? Cs173 - Spring 2004
P(6,4) x P(8,4) x P(3,2) x 3! CS 199 Permutations Suppose you have time to listen to 10 songs on your daily jog around campus. There are 6 Cake tunes, 8 Moby tunes, and 3 Eagles tunes to choose from. Finally, suppose you still want 4 Cake, 4 Moby, and 2 Eagles tunes, and the order of the groups doesn’t matter, but you get dizzy and fall down if all the songs by any one group aren’t played together. How many playlists are there now? Cs173 - Spring 2004
M2 M4 M5 M1 M3 5! X P(6,3) CS 199 Permutations In how many ways can 5 distinct Martians and 3 distinct Jovians stand in line, if no two Jovians stand together? Cs173 - Spring 2004
C(12,5) P(12,5) = C(12,5) x 5! CS173Combinations A basketball squad consists of 12 players, 5 of which make up a team. How many different teams of players can you make from the 12? What’s the diff? In a running race of 12 sprinters, each of the top 5 finishers receives a different medal. How many ways are there to award the 5 medals? Cs173 - Spring 2004
CS 199 Combinations A combination is an unordered selection of elements from some set. The number of combinations of r distinct objects chosen from n distinct objects is denoted by C(n,r) or nCr or , and is read “n choose r.” C(n,r) = P(n,r)/r! = n!/((n-r)!r!) Cs173 - Spring 2004
CS 199 Combinations A committee of 8 students is to be selected from a class consisting of 19 frosh, and 34 soph. In how many ways can 3 frosh and 5 soph be selected? Cs173 - Spring 2004
CS 199 Combinations A committee of 8 students is to be selected from a class consisting of 19 frosh, and 34 soph. In how many ways can a committee with exactly 1 frosh be selected? Cs173 - Spring 2004
CS 199 Combinations A committee of 8 students is to be selected from a class consisting of 19 frosh, and 34 soph. In how many ways can a committee with at most 1 frosh be selected? Cs173 - Spring 2004
CS 199 Combinations A committee of 8 students is to be selected from a class consisting of 19 frosh, and 34 soph. In how many ways can a committee with at least 1 frosh be selected? Cs173 - Spring 2004