算法導論(3版)第5章少量習題的解答

算法導論(3版)第5章

習題解答  by zevolo

5.2-3

indicator random variable
set X(i) = I(i)
    = 1  (when ith dot is show)
      0  (when ith dot is hide)
Now E(X) = E(X(1)) + E(X(2)) + E(X(3)) + .... + E(X(6)) means how many expected dots can show

we get X(1) = 1 (all sides show 1st dot), X(2) = 5/6, X(3) = 4/6, ...
    E(X) = P(X(1)) + P(X(2)) + ... + P(X(6))
         = 7/2

5.3-7
proof: use loop invariant
assume result set has the element with equally likely always
    1) it is easy to prove there is only one element.
    2) assume the assumption is right for k < m, that is for m - 1 subset from the n - 1,
       the probability is p = (m - 1) / (n - 1)
      then for the every element i ( 1 <= i and i < n), the probability is
         p(i) = p * 1 + (1 - p) * (1/n)
              = m / n
      for the element i (i = n) the probability is
         p(n) = 1 / n + ((m - 1)/n)
              = m / n
    3) prove the last


5.4-1
1) the probability is
         P(at least one who has same birthday with me) = 1 - P(no one has same birthday with me)
                              = 1 - P(B1) * P(B2|B1) * P(B3|B2&B1) * ... * P(Bk | B(k-1)&B(K-2)&...&B1)     Bi means i is not same birthday with me
                              = 1 - P(B1) * p(B2)    * P(B3)       * ... * P(Bk)                            Bi is independency
                              = 1 - ((n-1)/n) ^ k
        k = 253

2) the probability is
        P = 1 - P(no one birthday is 1.1) - P(only one birthday is 1.1)
          = 1 - ((n-1)/n) ^ k - sigma_1_k(P(i) * ((n-1)/n) ^ (k-1))
          = 1 - ((n-1)/n) ^ k - sigma_1_k((1/n) * ((n-1)/n) ^ (k-1))
          = 1 - ((n-1)/n) ^ k - (k/n) * ((n-1)/n) ^ (k-1)

        k = 613


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章