Building simple automations with AI tools in AI for Everyone - Time & Space Complexity
When building simple automations with AI tools, it is important to understand how the time needed grows as the tasks or data increase.
We want to know how the speed of the automation changes when we add more steps or handle more information.
Analyze the time complexity of the following automation process.
for each item in data_list:
analyze item with AI model
save result
if result meets condition:
trigger notification
This code runs an AI analysis on each item in a list, saves the result, and sends a notification if a condition is met.
Look for repeated actions that take most time.
- Primary operation: Running AI analysis on each item.
- How many times: Once for every item in the list.
As the list grows, the number of AI analyses grows the same way.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 AI analyses |
| 100 | 100 AI analyses |
| 1000 | 1000 AI analyses |
Pattern observation: The work grows directly with the number of items; doubling items doubles the work.
Time Complexity: O(n)
This means the time to complete the automation grows in a straight line with the number of items processed.
[X] Wrong: "Adding more items won't affect the time much because AI works fast."
[OK] Correct: Even if AI is fast, processing each item still takes time, so more items mean more total time.
Understanding how automation time grows helps you explain your design choices clearly and shows you think about efficiency in real projects.
"What if the AI analysis could process all items at once instead of one by one? How would the time complexity change?"