Lead scoring and nurturing in Digital Marketing - Time & Space Complexity
When managing lead scoring and nurturing, it's important to know how the time needed grows as you handle more leads.
We want to understand how the process scales when the number of leads increases.
Analyze the time complexity of the following lead scoring and nurturing process.
for lead in leads:
score = 0
for action in lead.actions:
score += action.weight
if score > threshold:
send_nurture_email(lead)
This code scores each lead by adding weights of their actions, then sends a nurturing email if the score passes a limit.
Look at what repeats as the input grows.
- Primary operation: Looping through each lead and then through each action of that lead.
- How many times: The outer loop runs once per lead (n times). The inner loop runs once per action for each lead (m times per lead).
As the number of leads and their actions grow, the work increases.
| Input Size (n leads, m actions each) | Approx. Operations |
|---|---|
| 10 leads, 5 actions | 50 operations |
| 100 leads, 5 actions | 500 operations |
| 1000 leads, 5 actions | 5000 operations |
Pattern observation: The total work grows roughly by multiplying the number of leads by the number of actions per lead.
Time Complexity: O(n * m)
This means the time needed grows in proportion to both the number of leads and the number of actions each lead has.
[X] Wrong: "The time only depends on the number of leads, not their actions."
[OK] Correct: Each lead's actions must be checked, so more actions mean more work, not just more leads.
Understanding how lead scoring scales helps you design systems that handle growing customer data smoothly and efficiently.
"What if we pre-calculate scores for actions and store them? How would that change the time complexity?"