Global EV adoption trends in EV Technology - Time & Space Complexity
We want to understand how the growth of electric vehicle (EV) adoption changes over time worldwide.
How does the number of EVs increase as more people and countries start using them?
Analyze the time complexity of the following simplified EV adoption model.
ev_count = 1
for year in range(1, n+1):
new_adopters = ev_count * growth_rate
ev_count += new_adopters
print(ev_count)
This code estimates EV numbers growing each year by a rate based on current adopters.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: A loop that runs once per year to update EV count.
- How many times: Exactly n times, where n is the number of years considered.
Each year, the EV count grows based on the previous year's total, causing a repeating calculation.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 loops, 10 updates |
| 100 | 100 loops, 100 updates |
| 1000 | 1000 loops, 1000 updates |
Pattern observation: The number of operations grows directly with the number of years.
Time Complexity: O(n)
This means the time to calculate EV adoption grows in a straight line as the number of years increases.
[X] Wrong: "The EV count calculation takes longer because the number of EVs grows exponentially."
[OK] Correct: The calculation only loops once per year, so time grows linearly, not exponentially, even if EV numbers grow fast.
Understanding how processes grow over time helps you explain trends clearly and think about scaling in real-world systems.
"What if the code also tracked monthly EV adoption instead of yearly? How would the time complexity change?"