0
0
Digital Marketingknowledge~5 mins

Attribution models (last-click, multi-touch) in Digital Marketing - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Attribution models (last-click, multi-touch)
O(n)
Understanding Time Complexity

When analyzing attribution models, we want to understand how the effort to assign credit grows as the number of customer interactions increases.

How does the time to calculate attribution change when more touchpoints are involved?

Scenario Under Consideration

Analyze the time complexity of the following simplified attribution calculation.


function calculateAttribution(touchpoints) {
  let credit = {};
  for (let i = 0; i < touchpoints.length; i++) {
    let channel = touchpoints[i];
    credit[channel] = (credit[channel] || 0) + 1;
  }
  return credit;
}
    

This code counts how many times each marketing channel appears in a customer's journey.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Looping through each touchpoint once.
  • How many times: Exactly once per touchpoint in the journey.
How Execution Grows With Input

As the number of touchpoints grows, the time to assign credit grows proportionally.

Input Size (n)Approx. Operations
1010 steps to count channels
100100 steps to count channels
10001000 steps to count channels

Pattern observation: Doubling touchpoints doubles the work needed.

Final Time Complexity

Time Complexity: O(n)

This means the time to calculate attribution grows directly with the number of touchpoints.

Common Mistake

[X] Wrong: "Attribution calculation time stays the same no matter how many touchpoints there are."

[OK] Correct: Each touchpoint must be checked to assign credit, so more touchpoints mean more work.

Interview Connect

Understanding how attribution calculations scale helps you explain data processing in marketing tools clearly and confidently.

Self-Check

What if we changed the model to assign credit only to the last touchpoint? How would the time complexity change?