Unformatted text preview: ˆ’ 2 = 16,777,214.
Continuing in this fashion we find the answer is: 3,737,091,842 (3.7 billion IP addresses)
12 Subtraction Rule
If a task can be done in either n1 ways or n2 ways,
then the number of ways to do the task is n1+n2
minus the number of ways to do the task that is
common to the two different ways.
Principle of InclusionandExclusion:
Let S1 and S2 be sets. Then
S1 âˆª S2 = S1+S2  S1 âˆ© S2
13 Subtraction Rule: Example 1
How many bit strings of length 8 either start with a 1 bit or end
with the last two bits equal to 00 ?
Let S1 be the set of bit strings of length 8 that start with 1.
Then S1 = 27=128.
Let S2 be the set of bit strings of length 8 that end with 00.
Then S2=26=64.
Furthermore, the set of bit strings of length 8 that start with
bit 1 and end with bits 00 has cardinality S1 âˆ© S2 = 25=32.
Thus, the answer is S1 âˆª S2=S1+S2S1 âˆ© S2=128+6432=160.
14 Subtraction Rule: Example 2
Let us consider some (slightly simplified) rules for passwords:
Passwords must be 2 characters long.
Each character must be
a) a letter [az],
b) a digit [09], or
c) one of the 10 special characters [!@#$%^&*()].
Each password must contain at least 1 digit or special
character. 15 Subtraction Rule: Example 2 (Cont.)
A legal password has a digit or a special character in position 1
or position 2.
These cases overlap, so the subtraction rule applies.
(# of passwords with valid symbol in position #1)
= (10+10)Â·(10+10+26)=20Â·46
(# of passwords with valid symbol in position #2) = 20Â·46
(# of passwords with valid symbols in both places): 20Â·20
Answer: 920+920âˆ’400 = 1,440
16 Pigeonhole Principle If k+1 objects are assigned to k places, then at
least one place must be assigned at least two
objects. 17 Generalized Pigeonhole Principle
Theorem: If N > k objects are assigned to k places, then at
least one place must be assigned at least ÈºN/kÈº objects.
Proof: Seeking a contradiction, suppose every place has less
than ÈºN/kÈº objects; so at most â‰¤ ÈºN/kÈºâˆ’1 objects per place.
Then the total number of objects is at most k ï¿¿ï¿¿ N
k ï¿¿ ï¿¿
ï¿¿ï¿¿
ï¿¿
ï¿¿
N
âˆ’1 <k
+ 1 âˆ’ 1 = k (N/k ) = N
k Thus, there...
View
Full
Document
This note was uploaded on 03/24/2014 for the course CSCE 222 taught by Professor Math during the Fall '11 term at Texas A&M.
 Fall '11
 math

Click to edit the document details