Download presentation

Presentation is loading. Please wait.

Published bySydnee Hold Modified over 3 years 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. How many bit-strings of length 7? We need to assign the first bit AND the second bit AND the third etc. total: 2x2x2.....2 = 2^7. 3. License plate has 3 letters and 3 digits: TAX 123. How many different license plates are possible? 26x26x26 x 10x10x10 = 17,576,000 4. How many one-to-one functions are there from a set A with m elements to a set B with n elements (m<n) ? First element from A has n choices in B. Second element has (n-1) choices etc. answer: nx(n-1)x(n-2)...x(n-m+1).

4
4.1 Counting 5. 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. 6. What is the number of elements in the Cartesian product of the sets A1,...,An? I.e. what is the cardinality of A1XA2X...XAn? a1 in (a1,a2,...,an) has |A1| possibilities, for every a1 there are |A2| possibilities for a2 etc. Total: |A1|x|A2|x...x|An|.

5
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. 3. What is the number of elements in the union set of the disjoint A1, A2,...,An? I.e. what is the cardinality Elements in the union can be in A1 OR A2 OR A3...: |A1|+|A2|+...+|An|.

6
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

7
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.

8
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. Tree Diagrams: For small problems you can enumerate all possibilities in a “decision tree”. Example: What is the total number of bit-strings of length 4 that do not have 2 consecutive 1’s? (white-board) Note: this approach becomes infeasible very quickly with growing number of possibilities.

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

10
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 more than. However, this number is smaller than n, which is a contradiction.

11
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. 2. For every positive integer n there is a multiple of n that consists of only o’s and 1’s. Consider the case n=3. Construct n+1 = 4 integers as follows: 1, 11, 111, 1111. Divide them by n to get: 0+1/3, 3+2/3, 37, 370+1/3 If we divide any integer by n, the possible remainders are: 0, 1/n, 2/n,...n-1/n. So in a list of n+1 remainders there must be two remainders the same: In this case: 1/3 = 0+1/3 and 1111=370+1/3 have the same remainder. If we subtract these two integers we get a new integer that is divisible by n: 1111-1 = 1110 = 3 x 370. Note that the difference must consist of all 0’s and 1’s!

12
4.1 Counting Examples: 3. We have 5 possible grades: A,B,C,D,E,F. How many students do we need to be sure at least 5 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. 4. Assume a telephone number is as follows: AA..A – XXXXX where X,A=[0..10]. How many area code digits do we need to make sure that 25 million people have different phone numbers. 25M =2.5x10^7 < 10^(5+k) k=3

13
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.

14
4.1 Counting Example: Every sequence of n^2+1 distinct real numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. e.g.: 4 2 6 1 9 (n=2). 4 2 1, or 2 6 9 proof: Let m=n^2+1 and denote the sequence with a1,a2,...,am. At each position we define a pair: (Li,Di) for the longest increasing and longest decreasing sequence starting at position i. Suppose there is no sequence of length at least n+1 decreasing or increasing. The number of possibilities of (Li,Di) = n^2. Thus by the pigeonhole principle, 2 pairs (Li,Di) and (Lj,Dj) of these are equal. However, assume first that ai < aj (they must be distinct). Starting at aj there is an increasing subsequence of length Lj: b1 b2 b3... If we now construct the sequence ai b1 b2 b3 then that has length Lj+1=Li CONTRADICTION same prove for ai > aj

15
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

OK

Section 6. 1. The Product Rule Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.

Section 6. 1. The Product Rule Example: How many different license plates can be made if each plate contains a sequence of three uppercase English letters.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on leverages synonym Ppt on computer animation Download ppt on floods in india Ppt on leadership styles in banking sector Ppt on dc motor working Ppt on law and social justice class 8 Download ppt on cell fundamental unit of life Ppt on mind reading machine Ppt on edgeworth box Medical templates free download ppt on pollution