What is a computer network in Computer Networks - Complexity Analysis
When we study computer networks, it helps to know how the time to send or receive data changes as the network grows.
We want to understand how the work needed changes when more devices join the network.
Analyze the time complexity of the following simple network message broadcast.
for each device in network:
send message to device
This code sends a message to every device connected in the network one by one.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Sending a message to each device.
- How many times: Once for every device in the network.
As the number of devices grows, the total messages sent grow at the same rate.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 messages sent |
| 100 | 100 messages sent |
| 1000 | 1000 messages sent |
Pattern observation: The work grows directly with the number of devices.
Time Complexity: O(n)
This means the time to send messages grows in a straight line as more devices join the network.
[X] Wrong: "Sending a message to all devices takes the same time no matter how many devices there are."
[OK] Correct: Each device needs its own message, so more devices mean more messages and more time.
Understanding how network tasks grow with devices helps you explain real-world network behavior clearly and confidently.
"What if the message was sent only to half the devices? How would the time complexity change?"