1 / 13

Counting: Product and Sum Rules

Counting: Product and Sum Rules. Product Rule: Assuming We need to perform procedure 1 AND procedure 2. There are n 1 ways to perform procedure 1 and n 2 ways to perform procedure 2. There are n 1 • n 2 ways to perform procedure 1 AND procedure 2. Sum Rule: Assuming

sblunt
Download Presentation

Counting: Product and Sum Rules

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Counting: Product and Sum Rules • Product Rule: Assuming • 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. • Sum Rule: Assuming • We need to perform 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. UCI ICS/Math 6A, Summer 2007

  2. Counting Examples: Product Rule Q. How many ways can we label a chair if each label consists of both a letter AND a number between 1 and 50, inclusive? There are 26 possibilities for the letter AND 50 for the number… A: 26x50=1300 Q. With 31 flavors of ice cream, 4 sizes of serving, and a choice of “cone” or “dish,” how many different orders of ice cream are there? A: 31x4x2=248 Q. What is the total number of subsets of a set A with n elements? That is, |P(A)| = ____? A: Representing each subset of A as a bitstring of length n (A=1111111…1, empty set=00000...0), |P(A)|=2n. UCI ICS/Math 6A, Summer 2007

  3. Counting Examples: Sum Rule Q: There is one position available for a faculty job at Irvine. The applicant must come from either Berkeley which has 20 candidates or UCLA which has 50 candidates. What is the total number of possible candidates for the position? A: The applicant must be from Berkeley OR UCLA. So we have 20+50=70 possible applicants. Q: At a resaurant, there are 18 dinners with meat, 10 different dinners with fish, and 5 vegetarian dinners? How many dinners to choose from? A: Each dinner is meat OR fish OR vegetarian. So we have 18+10+5=33 choices. UCI ICS/Math 6A, Summer 2007

  4. Counting Examples: Mixed Sum and Product 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? Total number is # passwords with 6 char. + # passwords with 7 char. + # pws 8 char. (=P6+P7+P8). P6: # possibilities without constraint : 366 # exclusions is # passwords without any digits is 266 And so, P6 = 366-266 Similarly, P7 = 367-267and P8 = 368-268 Giving a final answer of P = P6+P7+P8 = 366-266 + 367-267 + 368-268 UCI ICS/Math 6A, Summer 2007

  5. Counting: Inclusion–Exclusion Principle • Inclusion-Exclusion Principle: Assuming • We need to perform procedure 1 OR procedure 2. • There are n1 ways to perform procedure 1 and • n2 ways to perform procedure 2 and • m of the ways of doing procedures 1 and 2 are equivalent • There are (n1 +n2– m) ways to perform procedure 1 OR procedure 2. • (Recall: |AB| = |A| + |B| - |AB| ) UCI ICS/Math 6A, Summer 2007

  6. Counting Examples: Inclusion-Exclusion How many bit-strings of length 8 either begin with 1 or end with 00? A = 8-bit strings starting with 1 B = 8-bit strings starting with 00 What’s |AB| ? It’s |A| + |B| - |AB|: |A| = # of 8-bit strings starting with 1 is 27 |B| = # of 8-bit strings ending with 00 is 26 |AB| = # of 8-bit strings starting with 1 and ending with 00 is 25 Final Answer: |AB| = 27+ 26- 25 = |A| + |B| - |AB| UCI ICS/Math 6A, Summer 2007

  7. Tree Diagrams Use “tree diagrams” to organize (irregular) counting. How many bit strings of length 4 do not have two consecutive 1’s? 1 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 0 1 UCI ICS/Math 6A, Summer 2007

  8. Counting: Pigeonhole Principles Pigeonhole Principle: If we have n>k balls and we divide them among k boxes,then at least one box contains 2 balls. Generalized Pigeonhole Principle: If we have n>k balls and we divide them among k boxes,then at least one box contains at least n/k  balls. Example: k=5, n=1111/5  =3 UCI ICS/Math 6A, Summer 2007

  9. Proof of Generalized Pigeonhole Principle Claim: If # boxes = k and # balls = n then at least one box contains at least n/k  balls. Proof by Contradiction: Let us assume that PGG is not true, i.e.: (┐PGG): Each box has at most(n/k  - 1) balls So the total number of balls is at most k * (n/k - 1) Since n/k < n/k + 1, we have: # balls (=n) is at most k*(n/k - 1) < k*(n/k) = n. In other words, n < n, which is False! So assumption (┐PGG) leads to False. Therefore (┐PGG) is False. Therefore PGG is true. UCI ICS/Math 6A, Summer 2007

  10. Examples for Generalized Pigeonhole Principle 1. In a group of 366 people there are at least 2 people who have their birthday on the same day. 366/365 = 2. 2. We have 5 possible grades: A,B,C,D,E. How many students do we need to be sure at least 6 get the same grade? Try to fill the boxes evenly: If we have 25 students, then we can have 5 A’s, 5 B’s etc. So if we have 26 students, we need to add a student to some grade, and this grade will then have 6 students. Check: 26 / 5 = 6, but 25 / 5 = 5 UCI ICS/Math 6A, Summer 2007

  11. Example (“reverse PP”): Counting Connections Suppose we have 15 workstations and n=10 servers. Each server can handle only 1 workstation at a time. How many connections are needed s.t. any collection of 10 workstations can simultaneously access a server? k=60 connections suffice. Give each of the first 10 workstations a connection to its own server. Connect each of the remaining 5 to all 10 servers. Why does this work? k=59 connections are not enough. With 59 connections, at least 1 server (“S”) has at most 5 connections (This is “reverse pigeonhole”: k=10 boxes, n=59 balls, one box has ≤ n/k) Those 10 (or more) workstations not connected to S must be served by the 9 remaining servers. OUCH! UCI ICS/Math 6A, Summer 2007

  12. Counting Friends and Enemies If among a group of 6 people, every pair of persons is either an enemy or a friend, then there are at least 3 mutual friends or 3 mutual enemies. Proof: 1) Any person, A, has, from among the other 5 people, either (at least) 3 friends or (at least) 3 enemies of the 5. Why? 2) Assume “Without Loss Of Generality” (“wlog”), that A has (at least) 3 friends. 3) Either these 3 friends of A are all each others’ enemies (iwc* we are done) or at least 2 of them are (mutual) friends of each other, making A and them a trio of friends (iwc* we are done). * iwc = In Which Case UCI ICS/Math 6A, Summer 2007

  13. Monotone Sequences Every sequence of n2+1 distinct numbers contains a subsequence of n+1 numbers which is either strictly increasing or strictly decreasing. Example: “4,2,5,3,7” contains “4,5,7” Proof: Using a(k) to designate the kth term in the sequence, 1≤k≤n2+1 Let I(k) = length of longest increasing sequence starting at a(k) and D(k) = length of longest decreasing sequence starting at a(k). Unless the result is true, j ((1≤j≤n2+1) (1≤I(j),D(j)≤n)) Sincen2<n2+1, j,k ( (1≤j<k≤n2+1) (I(j),D(j)=(I(k),D(k) ) Now, eiither a(j)<a(k) or a(k)<a(j). If a(j)<a(k), adding a(j) to the beginning of the increasing sequence of length I(k) starting at a(k) produces an increasing sequence of length 1+I(k)=1+I(j) starting at a(j). Ouch! If a(k)<a(j), adding a(j) to the begining of the decreasing sequence of length D(k) starting at a(k) produces an decreasing sequence of length 1+D(k)=1+D(j) starting at a(j). Ouch! UCI ICS/Math 6A, Summer 2007

More Related