0
0
Digital Marketingknowledge~5 mins

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

Choose your learning style9 modes available
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?"