# after UCI ICS/Math 6A, Summer 2007 6-Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to.

## Presentation on theme: "after UCI ICS/Math 6A, Summer 2007 6-Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to."— Presentation transcript:

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to perform procedure 1 AND procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2. There are n 1n 2 ways to perform procedure 1 AND procedure 2. Sum Rule: Assuming a)We need to perform procedure 1 OR procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2. There are n 1 +n 2 ways to perform procedure 1 OR procedure 2. This “OR” is an “exclusive OR.” One choice or the other, but not both.

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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)|=2 n.

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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.

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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 : 36 6 # exclusions is # passwords without any digits is 26 6 And so, P6 = 36 6 -26 6 Similarly, P7 = 36 7 -26 7 and P8 = 36 8 -26 8 Giving a final answer of P = P6+P7+P8 = 36 6 -26 6 + 36 7 -26 7 + 36 8 -26 8

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-5 Counting: Inclusion–Exclusion Principle Inclusion-Exclusion Principle: Assuming a)We need to perform procedure 1 OR procedure 2. b)There are n 1 ways to perform procedure 1 and c)n 2 ways to perform procedure 2 and d)m of the ways of doing procedures 1 and 2 are equivalent There are (n 1 + n 2 – m) ways to perform procedure 1 OR procedure 2. (Recall: |A  B| = |A| + |B| - |A  B| )

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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 2 7 |B| = # of 8-bit strings ending with 00 is 2 6 | A  B| = # of 8-bit strings starting with 1 and ending with 00 is 2 5 Final Answer: |A  B| = 2 7 + 2 6 - 2 5 = |A| + |B| - |A  B|

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-7 Tree Diagrams Use “tree diagrams” to organize (irregular) counting. How many bit strings of length 4 do not have two consecutive 1’s? 10 0 0 01 11 111 0 0 00 0 00

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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.

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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!

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-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

sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-13 Monotone Sequences Every sequence of n 2 +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 k th term in the sequence, 1≤k≤n 2 +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).  j ( Unless the result is true,  j ((1≤j≤n 2 +1)  (1≤I(j),D(j)≤n)) Since n 2 { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/4035165/slides/slide_13.jpg", "name": "sjarecki@uci.edu, after franklin@uci.edu UCI ICS/Math 6A, Summer 2007 6-Counting-13 Monotone Sequences Every sequence of n 2 +1 distinct numbers contains a subsequence of n+1 numbers which is either strictly increasing or strictly decreasing.", "description": "Example: 4,2,5,3,7 contains 4,5,7 Proof: Using a(k) to designate the k th term in the sequence, 1≤k≤n 2 +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).  j ( Unless the result is true,  j ((1≤j≤n 2 +1)  (1≤I(j),D(j)≤n)) Since n 2

Download ppt "after UCI ICS/Math 6A, Summer 2007 6-Counting-1 Counting: Product and Sum Rules Product Rule: Assuming a)We need to."

Similar presentations