Download presentation

Presentation is loading. Please wait.

Published byDillan Catoe Modified about 1 year ago

1
Lecture 4 4.1,4.2 Counting

2
4.1 Counting Two Important Principles: Product Rule and Sum Rule. Product Rule: Assume we need to perform procedure 1 AND procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1xn2 ways to perform procedure 1 AND procedure 2. Sum Rule: Assume we need to perform procedure 1 OR procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1+n2 ways to perform procedure 1 OR procedure 2.

3
4.1 Counting Examples product rule: 1. We need to label chairs with a letter AND a number between [1...100]. What is the number of ways to label a chair? 26 possibilities to assign a letter, and for every letter there are 100 possibilities to assign a number. Total 2600. 2. What is the total number of subsets of a set A with n elements? I.e. what is the cardinality of the power-set P(A)? Recall that we can map A to a bit-string: 111111111111 (n times). Each subset is associated with a bunch of zeros. (00000...0 = empty set). Total # subsets therefore 2^n.

4
4.1 Counting Examples sum rule: 1. There is one position available for a PhD position at Irvine. The student 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. The candidate must be from Berkeley OR UCLA so we have 20+50=70 possible candidates. 2. There are 3 topics and each topic contains 20 projects. How many projects to choose from: 20+20+20=60.

5
4.1 Counting Mixed examples: 1. 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. P6 = 36^6-26^6 P7 = 36^7-26^7 P8 = 36^8-26^8 P = P6+P7+P8

6
4.1 Counting Inclusion – Exclusion Principle: Assume that m out of n1 ways to do procedure 1 are equivalent to m out of n2 ways to do procedure 2. Then the number of ways to perform procedure 1 OR procedure 2 are n1+n2-m. Example: There are 3 topics and 20 projects per topic, but 1 project is listed in all three topics. What is the total number of projects? 20+20+20 – 2 because one project was over-counted twice. Recall: The cardinality of the union set of overlapping sets A, B: Recall Sum Rule: Assume we need to perform procedure 1 OR procedure 2. There are n1 ways to perform procedure 1 and n2 ways to perform procedure 2. Then there are n1+n2 ways to perform procedure 1 OR procedure 2.

7
4.1 Counting Example: How many bit-strings of length 8 begin with either a 1 or end with 00? Total number of bit-strings starting with 1 is 2^7. Total number of bit-strings ending with 00 is 2^6 However, out of those 2^6 there are 2^5 bit-strings which stared with a one and were counted in the 2^7 of the first line. Conclusion: 2^7+2^6-2^5.

8
4.2 Counting 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 balls. k=5, n=11 =3

9
4.1 Counting Proof: Note that the following is true: ceiling function (e.g. 3 < 2.1 + 1 = 3.1) Therefore: This is the maximal number of balls if none of the boxes contains at least balls. However, this number is smaller than n, which is a contradiction. assume none of the boxes has at least balls.

10
4.1 Counting Examples: 1. In a group of 370 people there are at least 2 people who have their birthday on the same day. CEILING(370/365)=2. (days in a year = boxes, people is balls) 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 add a student to a grade which then has 6 students. (grades = boxes, students = balls)

11
4.1 Counting More examples: We have 15 workstations and 10 servers. We want that each subset of the 10 workstations can simultaneously access a server, while a server can only handle one workstation at a time. Prove that the minimal number of connections required is 60. Assume it is 59. Then one server S* must have at most 5 connections (if all servers had 6 connections we had 60 wires). Assume that the workstations that are not connected to S* (which are 10 in number) are the ones that try to make a connection. However, there are only 9 servers left..... A possible solution is this: connect the first 10 workstations to a unique server, and the remaining 5 to all servers. For any subset of 10 workstations, the uniquely wired workstations connect to their assigned server. The remaining ones pick an unoccupied server, which is always possible because they are connected to all of them.

12
4.1 Counting At a party of 6 people, every pair of persons is either an enemy or a friend. There are at least 3 mutual friend or 3 mutual enemies at the party. proof: Consider person A: it certainly has either 3 friends or 3 enemies at the party. (pigeonhole principle! 5 people in 2 categories. At least 2 of the same must exist). Assume they are friends. Are these 3 friends of A mutual friends? If they are all enemies: we have a collection of 3 enemies and we are done. If not, then at least 2 must be friends, which makes a group of three friends with A and we are done.

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google