Thus we have nn 1n m1 injective functions in this

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , we have n(n-1)...(n-m+1) injective functions in this case. 6 Sum Rule If a task can be done either in one of n1 ways or in one of n2 ways, where none of the set of n1 ways is the same as any of the set of n2 ways, then there are n1 + n2 ways to do the task. Let S1 and S2 be disjoint sets with n1=|S1| and n2=|S2|. Then |S1 ∪ S2| = n1+n2. 7 Sum Rule: Example 1 A student can choose a computer project from one of three lists. The three lists contain 23, 15, and 19 possible projects, respectively. No project is on more than one lists. How many possible projects are there to choose from? There are 23+15+19=57 projects to choose from. 8 Sum Rule: Example 2 How many sequences of 1s and 2s sum to n? Let us call the answer to this question an. a0 = 1 { one sequence, namely the empty sequence () } a1 = 1 { one sequence, namely (1) } a2 = 2 { the sequences (1,1) and (2) } a3 = 3 { the sequences (1,1,1), (1,2), and (2,1) } a4 = 5 { the sequences (1,1,1,1), (1,1,2), (1,2,1), (2,1,1), and (2,2) } 9 Sum Rule: Example 2 (Cont.) How many sequences of 1s and 2s sum to n? Let us call the answer to this question an. a0 = 1, a1 = 1 an = an-1 + an-2 for n >=2 Indeed, there are - an-1 sequences starting with 1 (remaining seq. summing to n-1) - an-2 sequences starting with 2 (remaining seq. summing to n-2) Thus, by the sum rule an = an-1 + an-2 Defining a-1=0, we get an=fn+1 where fn is the Fibonacci sequence. IPv4 Address Example Computer addresses belong to one of the following 3 types: – Class A: address contains a 7-bit “netid” ≠ 17, and a 24-bit “hostid” – Class B: address has a 14-bit netid and a 16-bit hostid. – Class C: address has 21-bit netid and an 8-bit hostid. Hostids that are all 0s or all 1s are not allowed. How many valid computer addresses are there? 11 IPv4 Address Example (Cont.) (# addrs) = (# class A) + (# class B) + (# class C) (by sum rule) # class A = (# valid netids)·(# valid hostids) (by product rule) (# valid class A netids) = 27 − 1 = 127. (# valid class A hostids) = 224 ...
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.

Ask a homework question - tutors are online