0
0
IOT Protocolsdevops~5 mins

Edge gateway architecture in IOT Protocols - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Edge gateway architecture
O(d x m)
Understanding Time Complexity

We want to understand how the work done by an edge gateway grows as it processes more devices or messages.

How does the time to handle data increase when more sensors connect to the gateway?

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


function processMessages(devices) {
  for (let device of devices) {
    let messages = device.getMessages();
    for (let msg of messages) {
      processMessage(msg);
    }
  }
}

This code processes messages from multiple devices connected to the edge gateway.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Nested loops over devices and their messages.
  • How many times: Outer loop runs once per device; inner loop runs once per message per device.
How Execution Grows With Input

As the number of devices and messages per device increase, the total work grows by multiplying these counts.

Input Size (devices x messages)Approx. Operations
10 devices x 5 messages50
100 devices x 5 messages500
100 devices x 100 messages10,000

Pattern observation: The total operations grow proportionally to the number of devices times the number of messages per device.

Final Time Complexity

Time Complexity: O(d * m)

This means the time grows in proportion to the number of devices times the messages each device sends.

Common Mistake

[X] Wrong: "The time grows only with the number of devices, ignoring messages."

[OK] Correct: Each device can send many messages, so total work depends on both devices and messages.

Interview Connect

Understanding how nested loops affect processing time helps you explain system performance clearly and confidently.

Self-Check

What if the gateway batches messages from all devices before processing? How would the time complexity change?