Probability Questions
Let
be some constant (independent of the input array length ). 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 times the size of the original array?
ANSWER: If the picked pivot is one of the smallest
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
, then each of its two recursive calls is passed a subarray with length between and (where is a fixed constant strictly between and ). 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 , from the minimum to the maximum number of recursive calls that might be needed.
ANSWER: If
If
Taking
By log rule
The best case is
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?
ANSWER: Option 1 is correct.
Consider a group of k people. Assume that each person’s birthday is drawn uniformly at random from the
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.]
ANSWER: For each pair of
If
Rewriting as a general quadratic equation
Since the number of people cannot be negative,
Let
denote the outcomes of three rolls of a six-sided die. (i.e., each 𝑋 1 , 𝑋 2 , 𝑋 3 is uniformly distributed among 𝑋 𝑖 , and by assumption they are independent.) Let 1 , 2 , 3 , 4 , 5 , 6 denote the product of 𝑌 and 𝑋 1 a n d 𝑋 2 the product of 𝑍 . Which of the following statements is correct? 𝑋 1 a n d 𝑋 3
- Y and Z are independent, but
𝐸 [ 𝑌 𝑍 ] ≠ 𝐸 [ 𝑌 ] ∗ 𝐸 [ 𝑍 ] - Y and Z are not independent, but
𝐸 [ 𝑌 𝑍 ] = 𝐸 [ 𝑌 ] ∗ 𝐸 [ 𝑍 ] - Y and Z are not independent, but
𝐸 [ 𝑌 𝑍 ] ≠ 𝐸 [ 𝑌 ] ∗ 𝐸 [ 𝑍 ] - Y and Z are independent, but
𝐸 [ 𝑌 𝑍 ] ≠ 𝐸 [ 𝑌 ] ∗ 𝐸 [ 𝑍 ]
ANSWER: For
Clearly,
Covariance reference: Expectations on the product of two dependent random variables
Clearly,
Leave a comment