Alarm acknowledgment workflow in SCADA systems - Time & Space Complexity
We want to understand how the time to acknowledge alarms grows as the number of alarms increases in a SCADA system.
How does the system handle more alarms without slowing down too much?
Analyze the time complexity of the following alarm acknowledgment workflow.
function acknowledgeAlarms(alarmList) {
for (let i = 0; i < alarmList.length; i++) {
if (alarmList[i].status == 'active') {
alarmList[i].status = 'acknowledged';
logAcknowledgment(alarmList[i]);
}
}
}
This code loops through all alarms and acknowledges each active alarm by changing its status and logging it.
Look for repeated actions in the code.
- Primary operation: Looping through each alarm in the alarm list.
- How many times: Once for every alarm in the list.
As the number of alarms increases, the time to process grows proportionally.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | About 10 checks and possible acknowledgments |
| 100 | About 100 checks and possible acknowledgments |
| 1000 | About 1000 checks and possible acknowledgments |
Pattern observation: The work grows evenly as the number of alarms grows.
Time Complexity: O(n)
This means the time to acknowledge alarms grows directly with the number of alarms.
[X] Wrong: "Acknowledging alarms happens instantly no matter how many alarms there are."
[OK] Correct: Each alarm must be checked and updated, so more alarms mean more work and more time.
Understanding how processes scale with input size is a key skill. It shows you can predict system behavior as it grows.
"What if the system only acknowledged alarms that met a certain priority? How would that change the time complexity?"