Referral program mechanics in Digital Marketing - Time & Space Complexity
When running a referral program, it's important to understand how the effort or cost grows as more users join and refer others.
We want to know how the number of operations changes as the number of participants increases.
Analyze the time complexity of the following referral program process.
// For each new user:
for each user in new_users:
send_invite(user)
for each referral in user.referrals:
reward_user(referral)
notify_user(referral)
update_program_stats()
This code sends invites to new users, rewards and notifies their referrals, and updates stats.
Look at the loops and repeated actions:
- Primary operation: Looping through each new user and then through each referral they bring.
- How many times: The outer loop runs once per new user; the inner loop runs once per referral of that user.
As the number of new users and their referrals grow, the total work grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 users with 2 referrals each | About 30 operations (10 invites + 20 rewards/notifications) |
| 100 users with 2 referrals each | About 300 operations |
| 1000 users with 2 referrals each | About 3000 operations |
Pattern observation: The total operations increase roughly in direct proportion to the number of users and their referrals.
Time Complexity: O(n)
This means the work grows linearly with the number of users and their referrals combined.
[X] Wrong: "The program runs in constant time because each user is handled separately."
[OK] Correct: Even though users are handled one by one, the total work depends on how many users and referrals there are, so it grows as more join.
Understanding how referral program operations grow helps you design scalable marketing strategies and shows you can think about efficiency in real-world systems.
"What if each user could have a varying number of referrals instead of a fixed number? How would the time complexity change?"
Practice
Solution
Step 1: Understand referral program goal
Referral programs aim to grow customer base by using existing customers as promoters.Step 2: Identify correct purpose
The main goal is to encourage current customers to invite others, increasing new customers.Final Answer:
To encourage existing customers to bring in new customers -> Option CQuick Check:
Referral programs = customer growth [OK]
- Thinking referral programs increase prices
- Believing referral programs reduce service quality
- Assuming referral programs limit customers
Solution
Step 1: Identify typical referral rewards
Referral programs usually offer incentives like discounts or free products to motivate sharing.Step 2: Match reward type
Free products or discounts are positive rewards, unlike fees or delays which discourage customers.Final Answer:
Free product or discount -> Option AQuick Check:
Referral rewards = discounts or freebies [OK]
- Confusing rewards with penalties
- Thinking referral rewards increase costs
- Assuming rewards reduce service quality
Solution
Step 1: Calculate full groups of 3 referrals
7 friends referred means 2 full groups of 3 (since 3*2=6), with 1 leftover.Step 2: Multiply groups by credit
2 groups x $10 credit = $20 total credit earned.Final Answer:
$20 -> Option DQuick Check:
Floor(7/3) x 10 = 20 [OK]
- Multiplying total referrals by $10 directly
- Ignoring leftover referrals
- Adding credit for incomplete groups
Solution
Step 1: Understand discount application rules
Most referral programs limit discounts to one per purchase to avoid stacking.Step 2: Identify why applying twice fails
Trying to apply the same discount twice likely violates the one-discount-per-purchase rule.Final Answer:
The program only allows one discount per purchase -> Option AQuick Check:
One discount per purchase rule = failure on double apply [OK]
- Assuming referee gets no discount
- Thinking discount percentage causes failure
- Believing referrer pays extra fees
Solution
Step 1: Understand program goal
The company wants to reward referrers only if new customers spend $50 or more.Step 2: Choose method ensuring fairness
Tracking purchases and rewarding only when spending meets $50 ensures fairness and avoids wasted rewards.Final Answer:
Track new customer purchases and only reward referrers when spending meets $50 -> Option BQuick Check:
Purchase tracking ensures fair rewards [OK]
- Rewarding referrers without purchase verification
- Ignoring purchase amount conditions
- Rewarding only new customers, not referrers
Ready to prove it?
Pass the test and this pattern moves unknown
