Discrete Math Exam 3
IPv4 Example
How many different IPv4 addresses are available for computers on the internet? Let Xa, Xb, and Xc be the number of addresses of class A, B, and C netids then Xa + Xb + Xc is the number of IPv4 addresses. Xa = ((2^7)-1) * ((2^240-2) = Xb = (2^14)*((2^16)-2) = Xc = (2^21)*((2^7)-2) =
Product Rule Example 4
How many different bit strings of length seven are there? _______ 2*2*2*2*2*2*2 = 2^7 = 128
Combinations Example One
How many different committees of three students can be formed from a group of four students? We find the number of subsets with three elements from the set containing the four students. S = {a,b,c,d} {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d} So four different committees of three students can be formed from a group of four students.
Division Rule Example Two
How many different ways are there to seat four people around a circular table, where two seating's are considered the same when each person has the same left neighbor and the same right neighbor. 24/4 = 6
Product Rule Functions
How many functions are there from a set with m elements to a set with n elements. Every element in the domain m is picked. Every possible combination of n is picked n^m
Product Rule One to One Functions
How many one-to-one functions are there from a set with m elements to one with n elements. When m>n there are none. If m ≤ n then there are n(n-1)(n-2)*...*(n-m+1) one-one functions.
Permutations Example Six
How many permutations of the letters ABCDEFGH contain the string ABC? ABC must be considered as a block (one character) and there are five letters after it. So it is equivalent to having to arrange six characters. 6! = 120
Binomial Coefficient Example Two
How many poker hands of five cards can be dealt from a standard deck of 52 cards? Also how many ways are there to select 47 cards from a standard deck of 52 cards? C(52,5) = 52! / (5!(52-5)!) = 52! / (5!*47!) = 2,598,960
Combinations Example
How many solutions does x1+x2+x3 = 11 have? Set C(3+11-1, 11) =
r Permutation Example Four
How many ways are there to select a first-prize winner, a second-prize winner, and a third-prize winner from 100 different people who have entered a contest? P(100,3) = 100!/(100-3)! = 100!/97! = 100*99*98 = 97020
Public Key Cryptosystem
Knowing how to send an encrypted message does not help decrypt messages. Everyone has a public encryption key. Only the decryption keys are kept secret.
Product Rule Example 2
The chairs of an auditorium are to be labeled with an uppercase English letter followed by a positive integer not exceeding 100. What is the largest number of chairs that can be labeled differently? 26*100 = 2600
Binomial Coefficient Theorem
The number of r-combinations of a set with n elements where n is a nonnegative integer and r is an integer with 0 ≤ r ≤ n is: C(n,r) = n! / (r!(n-r)!)
Product Rule Example 3
There are 32 computers in a data center in the cloud. Each of these computers has 24 ports. How many different computer ports are there in this data center? 32*24 = 768
The Division Rule
There are n/d ways to do a task if it can be done using a procedure that can be carried out in n ways and for every way w, exactly d of the n ways correspond to way w.
Transposition Cipher
A cipher that rearranges the order of characters in a message
Combinatorial Proof
A combinatorial proof of an identity is a proof that uses counting arguments to prove that both sides of an identity count the same objects but in different ways or a proof that is based on showing that there is a bijection between the sets of objects counted by two sides of the identity. These types of proofs are called doubling counting proofs and bijective proofs respectively.
Subtraction Rule Example Two
A computer company receives 350 applications from college graduates for a job planning a line of new web servers. Suppose that 220 of these applicants majored in computer science, 147 majored in business, and 51 majored in both computer science and business. How many of these applicants majored neither in computer science nor in business? (220 + 147) - 51 = 316. 350 - 316 = 34 34 applicants didn't major in business or computer science.
Cryptosystem
A cryptosystem is a five-tuple (P,C,K,E,D) where P is the set of plaintext strings, C is the set of ciphered strings, K is the keyspace (the set of all possible keys), E is the set of encryption functions and D is the set of decryption functions. We denote by Ek the encryption function in E corresponding to the key k and Dk the decryption function in D that decrypts ciphertext that was encrypted using Ek that is Dk(Ek(P)) = P for all plaintext strings P
Product Rule Example
A new company with just two employees, Sanchez and Patel, rents a floor of a building with 12 offices. How many ways are there to assign different offices to these two employees? We can assign any of 12 offices to Sanchez (12 ways) and any of 11 (because Sanchez is now occupying one) to to Patel. So we have 11*12 = 132
Permutation
A set of distinct objects in an ordered arrangement. An ordered arrangement of r elements of a set is called an r-permutation.
Another Shift Cipher Example
A=0, B=1, C=2, D=3, E=4, F=5, G=6, H=7, I=8, J=9, K=10, L=11, M=12, N=13, O=14, P=15, Q=16, R=17, S=18, T=19, U=20, V=21, W=22, X=23, Y=24, Z=25
IPv4
An IPv4 internet address is a string of 32 bits. It begins with a network number (netid) and the netid is followed by a host number (hostid), which identifies a computer as part of a particular network. Class A Addresses: Used for large networks. Consist of 0 followed by a 7bit netid and a 24bit hostid. Class B Addresses: Used for medium sized networks. Consist of 10 followed by a 14 bit netid and a 16bit host id. Class C Addresses: Used for the smallest networks. Consist of 110 followed by a 21 bit netid and an 8bit hostid.
r-combination
An r-combination of elements of a set is an unordered selection of r elements from the set. Thus an r-combination is simply a subset of the set with r elements. The number of r-combinations of a set with n distinct elements is denoted by C(n,r), the binomial coefficient.
Congruence Inverse Example
Find an inverse of 101mod(4620) First use Euclidean Algorithm gcd(101,4620) = 4620 = 101*45 + 75 101 = 75*1 + 26 75 = 26*2 + 23 26 = 23*1 + 3 23 = 3*7 + 2 3 = 1*2 + 1 2 = 2*1 So gcd(101,4620) = 1
Euclidean Algorithm Example
Find gcd(414,662) using the Euclidean algorithm 662 = 414*1+ 248 414 = 248*1 + 166 248 = 166*1 + 82 166 = 82*2 + 2 gcd(414,662) = gcd(82,2) = 2
Block Ciphers
Ciphers that replace a block of characters to avoid frequency analysis
Combinations
Combinations counts unordered selections of objects. Permutations count ordered selections of objects.
Solving Linear Congruences
First find the Bezout coefficients. One of them will be the inverse. Multiply the equation by the inverse.
Combination Counting Problems Example 1
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. How many possible passwords are there? P6 = 36^6 - 26^6 P7 = 36^7 - 26^7 P8 = 36^8 - 36^8 P6 + P7 + P8 is the number of passwords
RSA Encryption Example
Encrypt "STOP" using RSA with key (n=2537,e=13) Translate STOP into digits S=18, T=19, O=14, P=15 Since 2525 < 2537 < 252525 break it into two four letter blocks (2*4). 1819 1415 We encrypt each block using the mapping c = m^(13)mod(2537) Compute 1819^(13)mod(2537) = 2081 and 1415^(13)mod(2537) = 2182. The encrypted message is 2081 2182
Shift Cipher
Encryption method that shifts letters by a certain amount f(p) = f(p+k)mod(26) k is the amount it is shifted by. p is the letter we want to encrypt.
Subtraction Rule Example One
Example: How many bit strings of length eight either start with a 1 bit or end with the two bits 00? (2^7 + 2^6) - 2^5 = 128 + 64 - 32 = 160
Bezout's Theorem
If a and b are positive integers then there exist integers s and t such that gcd(a,b) = sa + tb. s and t are then Bezout Coefficients
Congruence Inverse Theorem
If a and m are relatively prime integers and m>1 then an inverse of amod(m) exists. Furthermore, this inverse is unique modulo m. That is, there is a unique positive integer α less than m that is an inverse of amod(m) and every other inverse of amod(m) is congruent to αmod(m).
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.
The 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 are common to both.
r-Permutation Theorem
If n is a positive integer and r is an integer with 1 ≤ r ≤ n then there are P(n,r) = n(n-1)(n-2)*...*(n-r+1) r-permutations of a set with n distinct elements. P(4,2) = 4(4-1)(4-2+1) = 4*3*3 = 36 If n and r are integers with 0 ≤ r ≤ n then P(n,r) = n! / (n-r)!
Private Key Cryptosystem
In a private key cryptosystem once you know an encryption key you can quickly find the decryption key. So knowing how to encrypt messages using a particular key allows you to decrypt messages that were encrypted using this key. The two parties that wish to communicate must share a secret key.
Permutation Example One
In how many ways can we select three students from a group of five students to stand in line for a picture? In how many ways can we arrange all five of these students in a line for a picture? First note the order matters. There are five ways to select the first students position. Since the first student is in line there are four ways for the next student to sit. Three ways for the third. So we have 5*4*3 = 60 We can arrange all five of the students in 5*4*3*2*1 = 120
Permutation Example Two
Let S = {1,2,3}. The ordered arrangement 3,1,2 is a permutation of S. The ordered arrangement 3, 2 is a 2-permutation of S.
Permutation Example Three
Let S = {a,b,c} then the 2-permutations of S are all possible two element sets in the power set of S. a,b; a,c; b,c; b,a; c,a; c,b; There are 6 2-permutations of S.
r-Combination Example One
Let S be the set {1,2,3,4} then {1,3,4} is a 3-combination from S.
Euclidean Algorithm
Let a=bq+r where a,b,q, and r are integers. Then gcd(a,b) = gcd(b,r).
Second Binomial Coefficient Theorem
Let n and r be nonnegative integers with r ≤ n. Then C(n,r) = C(n,n-r)
Bezout Coefficient Example
See Extended Euclidean Algorithm Page
Caesar Cipher
Shift each letter over by three f(p) = (p+3)mod(26) So, for example, "Hello" becomes.... A=0, B=1, C=2, D=3, E=4, F=5, G=6, H=7, I=8, J=9, K=10, L=11, M=12, N=13, O=14, P=15, Q=16, R=17, S=18, T=19, U=20, V=21, W=22, X=23, Y=24, Z=25 H = 7+3 = 10 = K E = 4+3 = 7 = H L = 11+3 = 14 = O L = 11+3 = 14 = O O = 14+3 = 17 = R So the Caesar cipher makes "Hello" be "KHOOR"
Sum Rule Example 2
Suppose a student can choose a computer project from one of three lists. The three lists contain 23, 15, and 19 possible integers. No project is on more than one list. How many possible projects are there to choose from? 23 + 15 + 19 = 57
Product Rule (Counting)
Suppose that a procedure can be broken down into a sequence of two tasks. If there are n1 ways to do the first task and for each of these ways of doing the first task there are n2 ways to do the second task then there are n1n2 ways to do the procedure.
Permutation Example Five
Suppose that a saleswoman has to visit eight different cities. She must begin her trip in a specified city but she can visit the other seven cities in any order she wishes. How many possible orders can the saleswoman use when visiting these cities? It is not 8! 7! = 5040
Division Rule Example One
Suppose that an automated system has been developed that counts the legs of cows in a pasture. Suppose that this system has determined that in a farmer's pasture there are exactly 572 legs. How many cows are there in this pasture assuming that each cow has four legs and there are no other animals present? 572/4 = 143 cows
Sum Rule Example 1
Suppose that either a member of the mathematics faculty or a student who is a mathematics major is chosen as a representative to a university community. How many different choices are there for this representative if there are 37 members of the mathematics faculty and 83 mathematics majors. No is both a mathematics faculty member and a student. 37+83 = 120
Transposition Cipher Example
Using the transposition cipher based on the permutation σ of the set {1,2,3,4} with σ(1) = 3, σ(2) = 1, σ(3) = 4, σ(4) = 2. Encrypt the plaintext message "PIRATE ATTACK" Put it into blocks of 4 since the magnitude of the set is 4. "PIRA" TEAT" "TACK" Then rearrange: "IAPR" "ETTA" "AKTC" IAPRETTAAKTC
Affine Cipher
f(p) = (ap+b)mod(26) So if we have B and we shift by b=10 then f(0) = (a*1 + 10)mod(26) What does the a do?