Bird
Raised Fist0
Digital Marketingknowledge~5 mins

A/B testing ad variations in Digital Marketing - Time & Space Complexity

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Time Complexity: A/B testing ad variations
O(n x m)
Understanding Time Complexity

When running A/B tests on ad variations, it's important to understand how the time to analyze results grows as you increase the number of ads or users.

We want to know how the effort changes when testing more ads or more audience members.

Scenario Under Consideration

Analyze the time complexity of the following process for A/B testing ad variations.


// For each ad variation
for each ad in ad_variations:
  // Show ad to each user in test group
  for each user in test_group:
    record user response to ad
  
// After collecting data, analyze results
analyze all recorded responses
    

This code shows how each ad variation is tested by every user, and then results are analyzed.

Identify Repeating Operations

Look at what repeats in this process.

  • Primary operation: Showing each ad to every user and recording their response.
  • How many times: For each ad variation, the process repeats for every user in the test group.
How Execution Grows With Input

As you add more ads or more users, the total work grows.

Input Size (ads x users)Approx. Operations
10 ads x 10 users100
100 ads x 100 users10,000
1000 ads x 1000 users1,000,000

Pattern observation: Doubling the number of ads and users multiplies the work by four, showing a fast growth in effort.

Final Time Complexity

Time Complexity: O(n x m)

This means the time grows proportionally to the number of ads times the number of users tested.

Common Mistake

[X] Wrong: "Testing more ads only increases time a little because users can see ads quickly."

[OK] Correct: Each new ad must be shown to every user, so the total time grows with both ads and users, not just one.

Interview Connect

Understanding how testing scales helps you plan campaigns and explain your approach clearly in discussions.

Self-Check

"What if we only test each ad with a random sample of users instead of all users? How would the time complexity change?"

Practice

(1/5)
1. What is the main purpose of A/B testing in digital marketing?
easy
A. To compare two versions of an ad to see which performs better
B. To create multiple ads without measuring results
C. To randomly show ads without any goal
D. To increase the budget of all ads equally

Solution

  1. Step 1: Understand the goal of A/B testing

    A/B testing is used to compare two versions of an ad to find out which one works better.
  2. Step 2: Identify the correct purpose from options

    Only To compare two versions of an ad to see which performs better describes comparing two ads to measure performance, which matches the goal of A/B testing.
  3. Final Answer:

    To compare two versions of an ad to see which performs better -> Option A
  4. Quick Check:

    A/B testing = Compare two ads [OK]
Hint: A/B testing compares two ads to find the best one [OK]
Common Mistakes:
  • Thinking A/B testing is just creating ads without measuring
  • Believing it increases budget automatically
  • Confusing random ad display with testing
2. Which of the following is the correct way to run an A/B test for ads?
easy
A. Show both ads to the same group at the same time
B. Show each ad to different but similar groups and compare results
C. Show only one ad and guess its performance
D. Change the ad daily without tracking results

Solution

  1. Step 1: Understand how A/B testing groups work

    Each ad version should be shown to different but similar groups to fairly compare performance.
  2. Step 2: Match the correct method with options

    Show each ad to different but similar groups and compare results correctly describes showing ads to different similar groups and comparing results.
  3. Final Answer:

    Show each ad to different but similar groups and compare results -> Option B
  4. Quick Check:

    Different groups + compare = A [OK]
Hint: Use similar groups for each ad to compare fairly [OK]
Common Mistakes:
  • Showing both ads to the same group at once
  • Not tracking or guessing results
  • Changing ads without measurement
3. You run an A/B test with two ads. Ad A gets 100 clicks from 1000 views, Ad B gets 150 clicks from 2000 views. Which ad has a better click-through rate (CTR)?
medium
A. Ad A with 10% CTR
B. Ad B with 7.5% CTR
C. Both have the same CTR
D. Cannot determine without more data

Solution

  1. Step 1: Calculate CTR for Ad A

    CTR = (Clicks / Views) x 100 = (100 / 1000) x 100 = 10%
  2. Step 2: Calculate CTR for Ad B

    CTR = (150 / 2000) x 100 = 7.5%
  3. Final Answer:

    Ad A with 10% CTR -> Option A
  4. Quick Check:

    CTR = clicks รท views x 100 [OK]
Hint: CTR = clicks divided by views times 100 [OK]
Common Mistakes:
  • Comparing clicks without considering views
  • Assuming more clicks means better CTR
  • Ignoring percentage calculation
4. You set up an A/B test but notice both ads are shown mostly to the same users. What is the main problem here?
medium
A. The budget is too low
B. The ads have different images
C. The ads are shown on different days
D. The test groups are not separated properly

Solution

  1. Step 1: Identify the issue with user exposure

    Showing both ads mostly to the same users means groups overlap, which breaks fair comparison.
  2. Step 2: Match problem to options

    The test groups are not separated properly correctly states the test groups are not separated properly, causing the issue.
  3. Final Answer:

    The test groups are not separated properly -> Option D
  4. Quick Check:

    Separate groups = fair test [OK]
Hint: Ensure separate groups to avoid overlap [OK]
Common Mistakes:
  • Blaming ad content instead of group setup
  • Thinking budget affects user overlap
  • Ignoring group separation importance
5. You want to test three ad headlines (A, B, C) but only have budget to run an A/B test. How can you apply A/B testing to find the best headline?
hard
A. Test all three headlines at once in one A/B test
B. Only test headline A and ignore others
C. Test A vs B first, then test the winner against C
D. Run ads without testing and pick the most popular later

Solution

  1. Step 1: Understand A/B testing limits

    A/B testing compares only two versions at a time, so testing three requires multiple rounds.
  2. Step 2: Apply sequential testing approach

    Test A vs B first, then test the winner against C to find the best headline.
  3. Final Answer:

    Test A vs B first, then test the winner against C -> Option C
  4. Quick Check:

    Sequential A/B tests find best among many [OK]
Hint: Test two ads at a time, then compare winner with next [OK]
Common Mistakes:
  • Trying to test three ads in one A/B test
  • Ignoring some headlines
  • Skipping testing and guessing results