Another approach to solving the problem (for those who have a difficult understanding of time, like me).
Firstly. Since we are talking about the “smaller of the two subarrays,” its length is less than 1/2 * n (n is the number of elements in the original array).
Second. If 0 <a <0.5 means that a * n is less than 1/2 * n. And therefore, we are now talking about two randomly selected integers, limited to 0 for the smallest and 1/2 * n for the highest.
Thirdly. Let's imagine the bones with numbers from 1 to 6 on the sides. Allows you to select a number from 1 to 6, for example 4. Now roll the bones. Each number has a probability of 1/6 to be the result of this throw. Thus, for the case "the result is less than or equal to 4", we have a probability equal to the sum of the probabilities of each of these results. And we have numbers 1, 2, 3 and 4. In total p (x <= 4) = 4 * 1/6 = 4/6 = 2/3. Thus, the probability of an event exceeding 4 is p (x> 4) = 1 - p (x <= 4) = 1 - 2/3 = 1/3.
Fourth. Let's get back to our problem. "Selected Number" is now * n. And we are going to throw a cube with numbers from 0 to (1/2 * n) on it to get k - the number of elements in the smallest of the subarrays. The probability that the result will be limited (a * n) at the maximum is equal to the sum of the probabilities of all outcomes from 0 to (a * n). The probability of any particular result k is p (k) = 1 / (1/2 * n).
Therefore, p (k <= a * n) = (a * n) * (1 / (1/2 * n)) = 2 * a.
From this we can easily conclude that p (k> a * n) = 1 - p (k <= a * n) = 1 - 2 * a.
source share