Incident indicators and alerts in Cybersecurity - Time & Space Complexity
When monitoring cybersecurity incidents, it's important to understand how the time to process indicators and alerts changes as more data comes in.
We want to know how the work grows when the number of incident indicators increases.
Analyze the time complexity of the following code snippet.
for indicator in incident_indicators:
if indicator.matches(alert):
send_alert_notification(indicator)
This code checks each incident indicator against an alert and sends a notification if there is a match.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each incident indicator to check for a match.
- How many times: Once for every indicator in the list.
As the number of incident indicators grows, the number of checks grows at the same rate.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: The work increases directly with the number of indicators.
Time Complexity: O(n)
This means the time to process alerts grows in a straight line as the number of incident indicators increases.
[X] Wrong: "Checking more indicators won't affect processing time much because computers are fast."
[OK] Correct: Even though computers are fast, each additional indicator adds more work, so processing time grows steadily with more data.
Understanding how processing time grows with data size helps you explain how alert systems scale and why efficient checks matter in real security work.
"What if we indexed the incident indicators for faster matching? How would the time complexity change?"