0
0
SCADA systemsdevops~5 mins

Data quality flags in SCADA systems - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Data quality flags
O(n)
Understanding Time Complexity

We want to understand how the time to check data quality flags changes as we handle more data points.

How does the work grow when we have more sensor readings to check?

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


for reading in sensor_readings:
    if reading.value < 0 or reading.value > reading.max_limit:
        reading.flag = 'error'
    else:
        reading.flag = 'ok'

This code checks each sensor reading and sets a flag based on whether the value is within limits.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Looping through each sensor reading once.
  • How many times: Once for every reading in the list.
How Execution Grows With Input

As the number of readings increases, the time to check flags grows directly with it.

Input Size (n)Approx. Operations
1010 checks
100100 checks
10001000 checks

Pattern observation: Doubling the readings doubles the work needed.

Final Time Complexity

Time Complexity: O(n)

This means the time to set flags grows in a straight line with the number of readings.

Common Mistake

[X] Wrong: "Checking flags is always fast and constant time no matter how many readings there are."

[OK] Correct: Each reading must be checked individually, so more readings mean more work.

Interview Connect

Understanding how work grows with data size helps you explain system behavior clearly and shows you can think about efficiency in real tasks.

Self-Check

"What if we added nested checks inside the loop for multiple conditions? How would the time complexity change?"