AWS Trusted Advisor recommendations - Time & Space Complexity
We want to understand how the time to get AWS Trusted Advisor recommendations changes as we ask for more checks.
How does the number of checks affect the total time to get all recommendations?
Analyze the time complexity of the following operation sequence.
// Pseudocode for fetching Trusted Advisor checks
client = new AwsTrustedAdvisorClient()
checks = client.describeChecks()
for (check in checks) {
result = client.describeCheckResult(check.id)
process(result)
}
This sequence fetches all available Trusted Advisor checks, then requests the results for each check one by one.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Calling
describeCheckResultfor each Trusted Advisor check. - How many times: Once per check, so as many times as there are checks.
As the number of Trusted Advisor checks increases, the number of API calls to get results grows directly with it.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 1 call to list checks + 10 calls to get results = 11 |
| 100 | 1 call to list checks + 100 calls to get results = 101 |
| 1000 | 1 call to list checks + 1000 calls to get results = 1001 |
Pattern observation: The total calls grow roughly in a straight line as the number of checks increases.
Time Complexity: O(n)
This means the time to get all recommendations grows directly in proportion to the number of checks.
[X] Wrong: "Getting all Trusted Advisor results takes the same time no matter how many checks there are."
[OK] Correct: Each check requires a separate API call to get its result, so more checks mean more calls and more time.
Understanding how API call counts grow with input size helps you design efficient cloud operations and explain your reasoning clearly in interviews.
"What if the API allowed fetching results for multiple checks in one call? How would the time complexity change?"