ADAS (Advanced Driver Assistance Systems) in EV Technology - Time & Space Complexity
Analyzing time complexity helps us understand how quickly an ADAS system processes data as the amount of sensor input grows.
We want to know how the system's work increases when it handles more information from the vehicle's environment.
Analyze the time complexity of the following ADAS sensor data processing code.
function processSensorData(sensorInputs) {
let alerts = [];
for (let i = 0; i < sensorInputs.length; i++) {
if (sensorInputs[i].distance < 10) {
alerts.push('Obstacle close');
}
}
return alerts;
}
This code checks each sensor input to find obstacles closer than 10 units and creates alerts for them.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each sensor input once.
- How many times: Exactly once per sensor input, so as many times as there are inputs.
As the number of sensor inputs grows, the system checks each one once, so work grows steadily.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: The number of operations grows directly with the number of inputs.
Time Complexity: O(n)
This means the processing time increases in a straight line as more sensor data comes in.
[X] Wrong: "The system only needs to check a few sensors, so time stays the same no matter how many inputs there are."
[OK] Correct: The code actually checks every sensor input once, so more inputs mean more work and longer processing time.
Understanding how ADAS systems handle growing sensor data helps you explain real-world system efficiency clearly and confidently.
"What if the system had to compare each sensor input with every other input? How would the time complexity change?"