System backup strategies in SCADA systems - Time & Space Complexity
When we back up a system, we want to know how the time it takes changes as the system grows.
We ask: How does backup time increase when there is more data to save?
Analyze the time complexity of the following backup process code.
// Backup all files in the system
function backupSystem(files) {
for (let i = 0; i < files.length; i++) {
backupFile(files[i]);
}
}
function backupFile(file) {
// Simulate file backup operation
saveToBackupStorage(file.data);
}
This code backs up each file one by one by saving its data to backup storage.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each file in the files list.
- How many times: Once for every file in the system.
As the number of files grows, the backup time grows in a straight line.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 file backups |
| 100 | 100 file backups |
| 1000 | 1000 file backups |
Pattern observation: Doubling the files doubles the backup time.
Time Complexity: O(n)
This means the backup time grows directly with the number of files to save.
[X] Wrong: "Backing up twice as many files takes the same time."
[OK] Correct: Each file needs its own backup step, so more files mean more time.
Understanding how backup time grows helps you explain system performance clearly and confidently.
"What if we only back up files that changed since the last backup? How would the time complexity change?"