Network topologies (star, bus, ring, mesh) in Computer Networks - Time & Space Complexity
When studying network topologies, it's important to understand how the time to send data grows as the network size increases.
We want to know how the structure affects communication speed and delays.
Analyze the time complexity of sending a message across different network topologies.
// Example: Sending a message from one node to another
// in different topologies
function sendMessage(topology, nodes, source, target) {
switch(topology) {
case 'star':
// Message goes from source to central hub, then to target
return 2; // two steps
case 'bus':
// Message travels along the bus until it reaches target
return distanceOnBus(source, target);
case 'ring':
// Message travels around the ring until target
return distanceOnRing(source, target);
case 'mesh':
// Direct connection between source and target
return 1; // one step
default:
return -1; // invalid topology
}
}
This code models how many steps a message takes to reach its destination in each topology.
Look at how many nodes the message passes through before reaching the target.
- Primary operation: Passing the message from one node to the next.
- How many times: Depends on the topology and distance between nodes.
As the number of nodes (n) grows, the message travel steps change differently for each topology.
| Input Size (n) | Star | Bus | Ring | Mesh |
|---|---|---|---|---|
| 10 | 2 steps | Up to 9 steps | Up to 5 steps | 1 step |
| 100 | 2 steps | Up to 99 steps | Up to 50 steps | 1 step |
| 1000 | 2 steps | Up to 999 steps | Up to 500 steps | 1 step |
Pattern observation: Star and mesh topologies keep message steps constant or very low, while bus grows linearly and ring grows roughly linearly with half the maximum distance.
Time Complexity: O(n) for bus and ring, O(1) for star and mesh
This means in bus and ring, message travel time grows with the number of nodes, but in star and mesh, it stays about the same no matter how big the network is.
[X] Wrong: "All network topologies have the same message travel time regardless of size."
[OK] Correct: Some topologies like bus and ring require messages to pass through many nodes, so time grows with network size, unlike star or mesh.
Understanding how network design affects message travel time helps you explain real-world trade-offs clearly and confidently.
"What if the mesh topology was only partially connected instead of fully connected? How would the time complexity change?"
Practice
Solution
Step 1: Understand the central device concept
Star topology connects all devices to one central device, which manages communication.Step 2: Compare with other topologies
Bus uses a single cable, ring connects devices in a circle, mesh connects devices directly to many others.Final Answer:
Star topology -> Option BQuick Check:
Central device = Star topology [OK]
- Confusing bus with star because both use cables
- Thinking ring has a central device
- Mixing mesh with star due to multiple connections
Solution
Step 1: Recall bus topology structure
Bus topology connects all devices along a single communication cable.Step 2: Eliminate other options
Closed loop is ring, every device connected is mesh, central hub is star.Final Answer:
All devices connected to a single cable -> Option CQuick Check:
Single cable = Bus topology [OK]
- Confusing ring (closed loop) with bus
- Thinking mesh is a single cable
- Mixing star's central hub with bus
Solution
Step 1: Understand ring topology communication
Devices are connected in a closed loop; data passes through each device.Step 2: Analyze failure impact
If one device fails, the loop breaks, stopping communication for all devices.Final Answer:
The entire network communication is disrupted -> Option DQuick Check:
One failure breaks ring loop = disruption [OK]
- Assuming only failed device loses connection
- Thinking ring has a backup path like mesh
- Confusing with star topology behavior
Solution
Step 1: Understand mesh topology traffic
Mesh connects devices directly; without control, many devices send data simultaneously.Step 2: Identify cause of collisions
Without a central controller or protocol, data packets collide causing errors.Final Answer:
There is no central device to control traffic -> Option AQuick Check:
No traffic control = collisions in mesh [OK]
- Confusing mesh with bus single cable
- Thinking ring causes collisions here
- Assuming one device can't cause collisions
Solution
Step 1: Identify topology with direct device-to-device connections
Mesh topology connects every device directly to all others, ensuring reliability.Step 2: Compare other topologies for reliability
Star depends on central hub, bus uses one cable, ring forms a loop but not all direct connections.Final Answer:
Mesh, because every device connects directly to all others -> Option AQuick Check:
Direct connections = Mesh topology [OK]
- Choosing star for reliability ignoring central point failure
- Thinking bus provides direct connections
- Confusing ring loop with full direct connections
Ready to prove it?
Pass the test and this pattern moves unknown
