MT2 Review CS 70, Summer 2019 Bonus Lecture, 8/2/19 1 / 23
The Tribe Has Spoken... We’ll go through these questions in order: I Short Answer (a selection of more frequently missed problems) I Probability (Shu ffl ing): parts (b) and (c) I Recursive Enumerability 2 / 23
2a) Suppose I have a deck of 52 cards and I lost 5 cards in the deck because I was careless. I shu ffl e the deck and take the top card. What is the probability that the card is a spade? 13 4 = ⇒ cards ④ 5 Nino lost on . 52T 3 / 23
2c) Find the number of non-negative integer solutions to x 1 + x 2 + x 3 = 30 where we have that at least one x i ≤ 5. -1%-173=30 Total Sols X , to bars 2 -1 bars ! ' * s Stars 30 , ( 322 ) #entXtXX30SXiZ6Vi * 'S 6 free " fix " 12 Stars each in 6¥ 6 bars 2 6* * * * * * w ' I ) ( X , Xi Xe . - f KL ) I 33 ) Ans ⇒ : 4 / 23
2e) Suppose we want to send n packets, and we know that our channel drops a fraction p of our packets, where 0 < p < 1. Using the R-S encoding from class, how many total packets should we send? " " -1k padding packets packets n . I Mtk )p = k Erasures : T T extra erasures # # packets . - k 7¥ solve fork - : L N Mtk = - x-p 5 / 23
2l) A dormitory has n ≥ 4 students, all of whom like to gossip. One of the students hears a rumor, and tells it to one of the other n − 1 students picked at random. After that, each student who hears the rumor tells it to another student picked uniformly at random, excluding themselves and the student who just told them the rumor. Let p r be the probability that the rumor is told at least r times without coming back to a student who has already heard it. 6 / 23
2l) Continued... w/out ith time told for Ri rumor is = someone going back to . A Rr ] n Ran Rs PER , . . . , R2 ] PCR , IR x x PCRZIR , ] PCR , ] × . . . = - 4 - 3 n n x I x x - I x . - = . 2 . N 2 N - - T can't tell # I person 7 / 23
7a) Given a playlist, the shu ffl e feature on Apple Music will play songs as a series of independent shu ffl e cycles . In each shu ffl e cycle, all songs in the list will be reordered, with each ordering equally likely. For instance, for a playlist of four songs a , b , c , d , one possible sequence of plays could be a b c d | b d c a | d a c b | . . . where we use | to separate the shu ffl e cycles. 8 / 23
7ai) Suppose I have an Apple Music playlist with exactly two songs , a and b . I have this playlist on shu ffl e while I’m away, so when I return, I could be at any position within a shu ffl e cycle with equal probability. When I return, a is playing. What is the probability that the next song is b ? 9 / 23
7aii) The next song played happened to be b . What is the probability that when I returned (i.e. when a was playing), it was the start of a shu ffl e cycle? 10 / 23
7b) Spotify’s shu ffl e feature works a little di ff erently. It instead selects any copy of any song from the playlist uniformly at random to play each time. I have a Spotify playlist with 5 copies of song a , 3 copies of song b , and 2 copies of song c (10 copies total). playlist a in Song select random at uniformly replacement with . 11 / 23
7bi) I shu ffl e my Spotify playlist for 6 song plays. If I ignore their play order , how many di ff erent sets of 6 plays could I have gotten? Give your answer as an integer. b.b.sc } ,a,a,b,b,c}t{ a .a , sets { : a **#*¥ 6 Stars bars 2 ( 821--28 12 / 23
7bii) What is the probability that across the 6 songs played on my Spotify shu ffl e, I get song a twice, song b twice, and song c twice? ( You may leave your answer unsimplified. ) . 612 bb } 1) these aa cc count 2 ! 2 ! ! bae bae individual seq of an prob 2) . - (0.5/40.3) 40.212 . cc ] Ca abb - Pr {z 10.5340-3340.29 ⇒ , 13 / 23
7c) YouTube Music’s (YTM) shu ffl e functionality is somewhere in between Apple Music’s and Spotify’s. Specifically, given a playlist of n songs, YTM will still play songs as a series of independent length- n shu ffl e cycles. However, each YTM cycle will behave like Apple Music’s shu ffl e feature (from part (a)) with probability p , and behave like Spotify’s shu ffl e feature (from part (b)) with probability 1 − p . I have a playlist with exactly two songs (one copy of each), a and b . I return when a (YTM) shu ffl e cycle is about to begin. ( Note: Each of the following answers may be in terms of p. ) 14 / 23
7ci) What is the probability that the first song I hear is a and the second is b ? t ab Apple - ga ab . - KHE ) Qb ¥ Spotify - + p - Probability Total : then b) happily = PKa -1 b) PCA then A Spotify ) pflathenb ) I pfzltu-fxff-EP.PE , 15 / 23
7cii) What is the probability that the second song I hear is b given that the first is a ? Tp fist . Apple z a seconder ✓ last <-PC¥ta I f part . Spotify a . a ] first n PC second b first a) IP ( second b) = ( ' ¥ lpffirst E a) Pz = = + = "¥=P¥ 16 / 23
5) A “halting converter” for a problem A is a program C that takes an instance of A as input " and: X pfmgraystrin.gl I If the correct answer for x is true, C(x) outputs a pair (P,y) such that P(y) halts. I If the correct answer for x is false, C(x) outputs a pair (P,y) such that P(y) loops forever. 17 / 23
5ai) Suppose we have a program C that is a halting converter for A . Fill in the description of R such that it is a recognizer for A . to X true Recognizer answer : If D : true - R returns false to X answer : 2) If false return R or loop . R Cx ) : Ctx ) - p , y - - Ply ) true return . 18 / 23
5aii) Prove that if the correct answer for x is true, R(x) will return true in finite time. RCX ) Intl : X If p ,y=CCX ) my ) halls - ⇒ Ply ) truer ⇒ return true return . 5aiii) Prove that if the correct answer for x is false, R(x) will return false or loop forever. - happen doesn't false If X ⇒ pay ) loop V loop pcx ) ⇒ 20 / 23
5bi) Suppose we have a recognizer R for A . Fill in the description of P such that, for an instance x of the problem A , P(x) halts if and only if the correct answer for x is true. p ( x ) : - Rtx ) y - true - is : if y return else : O ) loop LO f while forever . 21 / 23
5bii) Prove that if the correct answer for x is true, P(x) halts. p ( x ) : - Rtx ) true y X - true true - is : Rex ) if y ⇒ return ⇒ return ✓ else : O ) to while 5biii) Prove that if the correct answer for x is false, P(x) loops forever. false else clause x ⇒ false Rex ) D ⇒ Rtx ) will ⇒ RCX ) loops loop 2) y - - doesn't PCH ⇒ halt 22 / 23
5biv) Fill in the description of C below such that it is a halting converter for A . You may use the program P from part (bi), even if you did not complete that part. Ctx ) : P , X return 23 / 23
Recommend
More recommend