Risk assessment methodologies in Cybersecurity - Time & Space Complexity
Analyzing time complexity helps us understand how long a risk assessment process might take as the number of assets or threats grows.
We want to know how the effort increases when assessing more risks.
Analyze the time complexity of the following risk assessment steps.
for each asset in assets:
for each threat in threats:
evaluate_risk(asset, threat)
record_result
end
end
This code checks every threat against every asset to evaluate risks.
- Primary operation: Nested loops over assets and threats.
- How many times: For each asset, all threats are checked once.
As the number of assets and threats grows, the total checks grow by multiplying these numbers.
| Input Size (assets x threats) | Approx. Operations |
|---|---|
| 10 assets x 5 threats | 50 risk evaluations |
| 100 assets x 50 threats | 5,000 risk evaluations |
| 1,000 assets x 200 threats | 200,000 risk evaluations |
Pattern observation: The total work grows quickly as both assets and threats increase, multiplying together.
Time Complexity: O(n x m)
This means the time needed grows proportionally to the number of assets times the number of threats.
[X] Wrong: "Checking risks for one asset means the total time grows only with the number of assets."
[OK] Correct: Because each asset must be checked against all threats, the total time depends on both assets and threats, not just one.
Understanding how risk assessment scales shows you can think about workload and efficiency, a useful skill in cybersecurity roles.
"What if we only assessed risks for a fixed number of top threats instead of all threats? How would the time complexity change?"