Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
ELEC-270 Solutions to Assignment 6 1. How many strings of six lower-case letters of the English alphabet contain (a) the letters a and b in consecutive positions with a preceding b, with all the letters distinct? (b) the letters a and b where a is somewhere to the left of b in the string, with all the letters distinct? (a) First choose the position for the a; this can be done in 5 ways, since the b must follow it. There are four remaining positions, and these can be filled in P(24,4) ways, since there are 24 letters left (no repetitions being allowed this time). Therefore, the answer is 5 P(24,4) = 1275120. (b) First choose the positions for the a and b; this can be done in C(6,2) ways, since once we pick two positions, we put the a in the left-most and the b in the other. There are four remaining positions, and these can be filled in P(24,4) ways, since there are 24 letters left (no repetitions being allowed this time). Therefore, the answer is C(6,2) P(24,4) = 3825360. 2. There are 52 cards in a deck: 4 suits (hearts, diamonds, clubs, and spades) and 13 kinds in each suit (2, 3, … , 10, jack, queen, king, ace). Suppose that a 5-card poker hand is drawn. How many ways are there to draw a full house (i.e., three of a kind and a pair, e.g., three 7’s and two kings)? What is the probability of drawing a full house? Imagine that first you pick the number of ways to get 3 of a kind. There are 13 different kinds. So there are C(13, 1) ways to get one of the kinds. Then, there are 4 suits from which 3 of that kind is picked. I.e., there are C(13, 1) C(4, 3) ways to get 3 of a kind for 3 of 5 cards. Now, having picked those, there are only C(12, 1) possibilities for the kind of pair (since there can't be 5 of a kind). Since there are 4 suits and we must choose 2 from which to yield the pair, there are C(12, 1) C(4, 2) ways to get the pair once the 3 of a kind are picked. Therefore in total there are C(13, 1) C(4, 3) C(12, 1) C(4, 2) = 3744 ways to get a full house. 3744 Probability C(52, 5) 1.44 10 3 3. (a) Consider the following game. You get two red cards and five black cards, face down. Then, you start turning over the cards one by one. If you turn over both red cards before turning over a black card, you win. Alternatively, if you turn over all five black cards before turning over a red card, you win. Which way would you prefer to play the game? I.e., calculate the probability of winning either way. (b) Let’s see if the result in (a) generalizes. If you are given r red cards and b black cards face down, what are the probabilities of winning the game played in two ways? (I.e., in one case you have to get all r red cards before turning over a black card and in the other you have to get all b black cards before turning over a red card.) (a) i. Game is over once two cards are picked (since either you’ve gotten 2 red cards or you’ve hit a black card). There are C(7, 2) ways to pick two cards. How many ways are there to get the two of them being red? C(2, 2) C(5, 0) = 11 = 1 (which is obvious since the only “choice” is red red) C(2, 2) C(5, 0) So, probability of winning is C(7, 2) 7! 76 C(7,2) 2!5! 2 2 1 Probability of winning is 7 6 21 ii. Game is over once five cards are picked. There are C(7, 5) ways to pick five cards. C(5, 5) C(2, 0) So, probability of winning is C(7, 5) 7! C(7, 5) 5!2! 1 1 Probability of winning is 76 . 21 2 No preference on which way to play the game. (a) In general, C(r , r ) C(b,0) . C((r b), r ) C(b, b) C(r ,0) . probability of winning by picking all blacks is: C((r b), b) ( r b) ! ( r b) ! . denom of 1st one is r ! (r b r ) ! r !b ! ( r b) ! ( r b) ! . denom of 2nd one is b ! ( r b b) ! b!r ! numerator of both is 1. probability of winning by picking all reds is: same probability of winning either way. 4. (a) Suppose that p and q are primes and n = pq. What is the probability that a randomly chosen positive integer less than n is not divisible by p or q? (b) Recall the remark on p. 301 of the textbook that for RSA decryption, it can be assumed that for gcd(M, p) = gcd(M, q) = 1, since those equations hold in all but rare cases (where M < n). Let’s quantify this claim for a couple of cases. i. Using the result from (a), if p = 97 and q =113, what is the probability that an integer (M, representing the plaintext in an RSA cryptosystem) that is less than pq is not divisible by 97 or 113? ii. Using the result from (a), if p = 199 and q =211, what is the probability that an integer that is less than pq is not divisible by 199 or 211? iii. Comment on (i) and (ii). I.e., what happens as p and q get large? In particular, for RSA systems, the primes typically used are 200 digits long. (a) We need to determine how many positive integers less than n = pq are divisible by either p or q. The numbers p, 2p, 3p, … , (q 1)p are all divisible by p. This gives q 1 numbers. Similarly, p 1 numbers are divisible by q. None of these numbers is divisible by both p and q. (To see this, recall that for a number m and a prime p, mp could only be divisible by q if m were divisible by q since p is prime and is not divisible by any number except 1 and p. But if m is less than q and all the numbers from 1, 2, …, q 1 are less than q, then m can't be divisible by q. Similar reasoning shows why mq couldn't be divisible by p for m in the range of 1,2, …, p 1.) Therefore, p + q 2 numbers in this range are divisible by p or q , so the remaining pq 1 (p + q 2) (which equals pq p q +1 = (p 1)(q 1)) are not. Therefore, the probability that a randomly chosen integer in this range is ( p 1)(q 1) not divisible by either p or q is pq 1 (b) (i) p = 97, q = 113 prob = ( p 1)(q 1) 96 112 0.981 97 113 1 pq 1 p = 199, q = 211 ( p 1)(q 1) 198 210 0.99 prob = pq 1 198 211 1 (iii) As p and q get large, the probability goes to 1. This is because p 1 p for very large p q 1 q for very large q pq 1 pq for very large p, q (ii) pq ( p 1)(q 1) 1 for very large p, q pq 1 pq