bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Data Interview Question

Ad Display Strategies in Newsfeed

bugfree Icon

Hello, I am bugfree Assistant. Feel free to ask me for any question related to this problem

Solution & Explanation

Option 1: One ad is shown for every 25 stories

In this strategy, the placement of ads is deterministic. For every 25 stories, exactly one ad is shown. Therefore, in a sequence of 100 stories:

  • Expected number of ads:

    E(No. of ads in 100 stories)=10025=4\mathbb{E}\left(\text{No. of ads in 100 stories}\right) = \frac{100}{25} = 4

    This means that on average, a user will see 4 ads in 100 stories.

Option 2: Each story has a 4% probability of being an ad

In this strategy, each story independently has a 4% chance of being an ad. This follows a binomial distribution with parameters n=100n = 100 (number of trials) and p=0.04p = 0.04 (probability of success, i.e., a story being an ad).

  • Expected number of ads:

    The expected value for a binomial distribution Binomial(n,p)\text{Binomial}(n, p) is given by:

    E[X]=np\mathbb{E}[X] = n \cdot p

    Substituting the given values:

    E[No. of ads in 100 stories]=100×0.04=4\mathbb{E}[\text{No. of ads in 100 stories}] = 100 \times 0.04 = 4

    Like the first strategy, the expected number of ads in 100 stories is also 4.

  • Probability of exactly one ad in 100 stories:

    This requires calculating the probability of exactly one success (ad) in 100 trials (stories), which is given by the probability mass function (PMF) of the binomial distribution:

    P(X=1)=(nx)px(1p)nx\mathbb{P}(X = 1) = {n \choose x} \cdot p^x \cdot (1-p)^{n-x}

    Substituting the values:

    P(X=1)=(1001)(0.04)1(0.96)99\mathbb{P}(X = 1) = {100 \choose 1} \cdot (0.04)^1 \cdot (0.96)^{99}

    • Calculation:

      (1001)=100{100 \choose 1} = 100

      (0.04)1=0.04(0.04)^1 = 0.04

      (0.96)990.01757(0.96)^{99} \approx 0.01757

    • Result:

      P(X=1)=100×0.04×0.017570.0703\mathbb{P}(X = 1) = 100 \times 0.04 \times 0.01757 \approx 0.0703

    Therefore, if the second strategy is chosen, the probability that a user sees exactly one ad in 100 stories is approximately 7.03%.

Summary

  • Both strategies result in an expected number of 4 ads in 100 stories.
  • The probability of seeing exactly one ad in the second strategy is approximately 7.03%.