All Coursera Quiz Answers

Problem Set #3 Quiz Answer

In this article i am gone to share Coursera Course Divide and Conquer, Sorting and Searching, and Randomized Algorithms Week 3 | Problem Set #3 Quiz Answer with you..

Divide and Conquer, Sorting and
Searching, and Randomized Algorithms


Also visit this link:ย  Problem Set #2 Quiz Answer


 

Problem Set #3 Quiz Answer

Question 1) Let 0 < a <.5 be some constant (independent of the input array length n). Recall the Partition subroutine employed by the QuickSort algorithm, as explained in lecture. What is the probability that, with a randomly chosen pivot element, the Partition subroutine produces a split in which the size of the smaller of the two subarrays is โ‰ฅ a times the size of the original array?

  • 1 โ€“ 2 โœฒ a
  • a
  • 1 โ€“ a
  • 2 โ€“ 2โœฒa

ย 

Question 2) Now assume that you achieve the approximately balanced splits above in every recursive call —that is, assume that whenever a recursive call is given an array of length k, then each of its two recursive calls is passed a subarray with length between ak and (1 – a)k (where a is a fixed constant strictly between 0 and.5). How many recursive calls can occur before you hit the base case? Equivalently, which levels of the recursion tree can contain leaves? Express your answer as a range of possible numbers d, from the minimum to the maximum number of recursive calls that might be needed.

Problem Set #3 Quiz Answer

Question 3) Define the recursion depth of QuickSort to be the maximum number of successive recursive calls before it hits the base case — equivalently, the number of the last level of the corresponding recursion tree. Note that the recursion depth is a random variable, which depends on which pivots get chosen. What is the minimum-possible and maximum-possible recursion depth of QuickSort, respectively?

  • Minimum: ฮ˜(log(n)); Maximum: ฮ˜(n)
  • Minimum: ฮ˜(log(n)); Maximum: ฮ˜(n log(n))
  • Minimum: ฮ˜(1); Maximum: ฮ˜(n)
  • Minimum: ฮ˜(โˆšn); Maximum: ฮ˜(n)

 

Question 4) Consider a group of k people. Assume that each person’s birthday is drawn uniformly at random from the 365 possibilities. (And ignore leap years.) What is the smallest value of k such that the expected number of pairs of distinct people with the same birthday is at least one?

[Hint: define an indicator random variable for each ordered pair of people. Use linearity of expectation.]

  • 28
  • 27
  • 20
  • 23
  • 366
ย 

Question 5) Let X1, X2, X3 denote the outcomes of three rolls of a six-sided die. (l.e., each Xiย  is uniformly distributed among 1,2,3,4,5,6, and by assumption they are independent.) Let Y denote the product of X1 and X2 and Z the product of X2 and X3. Which of the following statements is correct?

  • Y and Z are independent, but E[Y โœฑ Z] โ‰  E[Y]โœฑ E[Z].
  • Y and Z are independent, and E[Y โœฑ Z] โ‰  E(Y] โœฑ E[Z].
  • Y and Z are not independent, and E[Y โœฑ Z] โ‰  E(Y] โœฑ E[Z].
  • Y and Z are not independent, but E[Y โœฑ Z] โ‰  E(Y] โœฑ E[Z].