0
0
Digital Marketingknowledge~5 mins

Audience targeting (demographics, interests, lookalike) in Digital Marketing - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Audience targeting (demographics, interests, lookalike)
O(n + m * k)
Understanding Time Complexity

When setting up audience targeting in digital marketing, it is important to understand how the time to process and deliver ads grows as the audience size or targeting criteria increase.

We want to know how the system handles more data and complex targeting rules efficiently.

Scenario Under Consideration

Analyze the time complexity of this simplified audience targeting process.


// Pseudocode for audience targeting
for each user in user_database:
  if user matches demographics:
    if user matches interests:
      add user to target_list
for each user in target_list:
  find lookalike users
  add lookalike users to final_audience
    

This code filters users by demographics and interests, then expands the audience by adding lookalike users.

Identify Repeating Operations

Look at the loops and repeated checks:

  • Primary operation: Looping through all users in the database to filter by demographics and interests.
  • How many times: Once for each user, so the number of users (n).
  • Then, for each user in the filtered list, finding lookalike users involves another loop or search.
  • This second step depends on the size of the filtered list (m), which is less than or equal to n.
How Execution Grows With Input

As the number of users grows, the filtering step checks each user once.

Input Size (n)Approx. Operations
10About 10 checks for filtering + lookalike searches
100About 100 checks + more lookalike searches
1000About 1000 checks + even more lookalike searches

Pattern observation: The time grows roughly in proportion to the number of users and the filtered audience size.

Final Time Complexity

Time Complexity: O(n + m * k)

This means the time grows linearly with the total users (n) plus the filtered users (m) times the number of lookalike users found per filtered user (k).

Common Mistake

[X] Wrong: "Audience targeting always takes the same time no matter how many users there are."

[OK] Correct: The system must check each user against targeting rules, so more users mean more work and longer processing time.

Interview Connect

Understanding how audience size and targeting criteria affect processing time helps you design efficient marketing campaigns and systems, a valuable skill in digital marketing roles.

Self-Check

"What if the lookalike search used a precomputed index instead of searching each time? How would the time complexity change?"