Week04Lecture2 Counting Approximation PIE
Week04Lecture2 Counting Approximation PIE
Muhammad Sauood
Email: [email protected]
Office Hours:
-My office:
Monday: 10:00 – 17:30
Cabin-7, F-304, A-Building
Wednesday: 10:00 – 17:00
or by appointment (email)
Recap
Permutations
Combinations
Approximate Number of Subsets (Section 1.4)
• Number of subsets of an n–set
1267650600228229401496703206376
• Recall:
Approximate Number of Subsets (Section 1.4)
• Number of subsets of an 100–set
• Recall:
has 31 digits
Powers of 2 vs. Powers of 10
• Just remember
Powers of 2 vs powers of 10
Powers of 2 vs. Powers of 10
• Just remember
Powers of 2 vs powers of 10
----- ( 2’s)
----- ( n’s)
Comparing and Estimating Numbers (Section 2.2)
How large is ?
How many digits does it have?
n–set has more permutations () or more subsets ()?
Then A ∪ B = {1,2,3,4,5,6,7}.
By inspection, |A∪B| = 7, but you can also verify that |A∪B| = 7 = 5 +
5−3 = |A|+|B|−|A∩B|.
Examples: PIE --- Do it by yourself
Problem 2
How many positive integers not bigger than 20 are divisible by either 2
or 3?
Solution:
There are that begin with 00, that end with 101, and that start with 00
and end with 101. So the number of bit strings with at least one of the
two properties is .
Examples: PIE --- Do it by yourself
Problem 7: Counting Passwords again
Each user on a computer system has a password, which is six to eight
characters long, where each character is an uppercase letter, lower case letter
or a digit. Each password must contain at least ONE DIGIT, ONE UPPER
CASE and ONE LOWER CASE letter. How many possible passwords are
there?
Illegal passwords = Only upper or lower case letters + Only upper case or
digits + Only lower case or digits – Only upper case letters – only lower case
letters – only digits
Examples: PIE --- Do it by yourself
Problem 7: Counting Passwords again
Each user on a computer system has a password, which is six to eight
characters long, where each character is an uppercase letter or a digit.
Each password must contain at least ONE DIGIT, ONE UPPER CASE
and ONE LOWER CASE letter. How many possible passwords are
there?
Solution:
(All Passwords) – (Small and Capital ONLY) – (Small and Digits)
– (Capital and Digits) ???
Examples: PIE --- Do it by yourself
Problem 7: Counting Passwords again
Each user on a computer system has a password, which is six to eight
characters long, where each character is an uppercase letter or a digit.
Each password must contain at least ONE DIGIT, ONE UPPER CASE
and ONE LOWER CASE letter. How many possible passwords are
there?
Solution:
(All Passwords) – (Small and Capital ONLY) – (Small and Digits)
– (Capital and Digits) + (Small only) + (capital) + (Digits)
YouTube Videos: (to help you in lecture slides and book–reading)
Xie Xie!!!
Note:
Assignment-1 Deadline: November 18
Quiz Be Ready … in any class (unannounced)
MORE PRACTICE
PROBLEMS
Do it by yourself
Examples: PIE --- Do it by yourself
Venn Diagram???
Extension of PIE
Finding a Formula for the Number of Elements in the Union of Three Sets.
Problem: Application of PIE
Try it at your own:
Principle of Inclusion-Exclusion
In a survey on the college students, the following data was obtained:
• 78 like Vanilla Ice-cream
• 32 like Chocolate
• 57 like Mango Ice-cream
• 13 like both Vanilla Ice-cream and Chocolate
• 21 like both Chocolate and Mango Ice-cream
• 16 like both Mango Ice-cream and Vanilla Ice-cream
• 5 like all three flavors above
• 14 like none of these three flavors
How many students were surveyed?
Self-assessment Quiz:
Solution: All except the empty set and the eight singletons, so
altogether subsets contain more than one element.
Try it at your own:
Self-assessment Quiz:
• How many bit strings of length 8 either start with 01 or end with 01?
In a mathematics contest with three problems, 80% of the participants solved the first
problem, 75% solved the second and 70% solved the third.
Prove that at least 25% of the participants solved all three problems.
====================================================
Solution: Let the total number of participants be n > 0 (if n = 0, the proof is trivial).
Denote the set of people who missed the first problem by A, the set of people who missed
the second by B, and the set who missed the third by C.
We know that |A| = n −0.8n = 0.2n, |B| = n −0.75n = 0.25n and |C|= n−0.7n = 0.3n.
We also know, that |A∪B∪C|≤|A|+|B|+|C|= 0.2n +0.25n +0.3n = 0.75n
The set of people who solved all three problems is the complement of A ∪B ∪C (the set who
missed at least one problem), so it has size
n−|A∪B∪C|≥ n−0.75n = 0.25n
Therefore at least 25% of the participants solved all three problems.
Try it at your own:
Number of strings with 3 consecutive zeros = 25+5×24=11225+5×24=112 , because the 3 zeros can start at bit number 1, 2, 3, .., 6
Number of strings with 4 consecutive ones = 24+4×23=4824+4×23=48 , I used the same reasoning.
Now I am trying to count the number of bit-strings that contain both 3 consecutive zeros and 4 consecutive 1s. I reasoned as follows:
the strings can be of the following forms: 0001111x, 000x1111, x0001111.. thus there are 2+2+2=62+2+2=6 possibilities for bit-strings where the 3 consecutive zeros come first.
Symmetrically there are 66 bit-strings where the 4 consecutive ones come first.
Thus the answer should be = 112+48−12=148112+48−12=148 .
So 00010000, 00010001, 00001000, 00011000, 10001000, 00010000, 00010001, 00001000, 00011000, 10001000 were added to your total twice.
This didn't cause any problems in your count of strings with four 11 s, however, since we can't put four 11 s in two separated places in an 88 -bit string.
So the union now has155 elements, and cutting out the two duplicates from each symmetry of your intersection calculation turns that to 88 ,
for a total 107+48−8=147107+48−8=147