0
0
AWScloud~5 mins

AWS Trusted Advisor recommendations - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: AWS Trusted Advisor recommendations
O(n)
Understanding Time 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?

Scenario Under Consideration

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 Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: Calling describeCheckResult for each Trusted Advisor check.
  • How many times: Once per check, so as many times as there are checks.
How Execution Grows With Input

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
101 call to list checks + 10 calls to get results = 11
1001 call to list checks + 100 calls to get results = 101
10001 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.

Final Time Complexity

Time Complexity: O(n)

This means the time to get all recommendations grows directly in proportion to the number of checks.

Common Mistake

[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.

Interview Connect

Understanding how API call counts grow with input size helps you design efficient cloud operations and explain your reasoning clearly in interviews.

Self-Check

"What if the API allowed fetching results for multiple checks in one call? How would the time complexity change?"