0
0
Azurecloud~5 mins

Users and groups in Azure - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Users and groups
O(n)
Understanding Time Complexity

When managing users and groups in Azure, it's important to understand how the time to complete tasks grows as you add more users or groups.

We want to know how the number of operations changes when we add more users to groups.

Scenario Under Consideration

Analyze the time complexity of adding multiple users to a group.


// Add users to a group in Azure AD
foreach (var user in usersList) {
    await graphClient.Groups[groupId].Members.References.Request().AddAsync(user);
}
    

This code adds each user from a list to a single Azure AD group one by one.

Identify Repeating Operations

Look at what repeats as the list grows:

  • Primary operation: API call to add one user to the group.
  • How many times: Once for each user in the list.
How Execution Grows With Input

As you add more users, the number of API calls grows directly with the number of users.

Input Size (n)Approx. API Calls/Operations
1010
100100
10001000

Pattern observation: Each new user adds exactly one more operation, so the total grows steadily.

Final Time Complexity

Time Complexity: O(n)

This means the time to add users grows in a straight line with the number of users.

Common Mistake

[X] Wrong: "Adding multiple users to a group is done in one single API call, so time stays the same no matter how many users."

[OK] Correct: Each user requires a separate API call, so time grows with the number of users.

Interview Connect

Understanding how operations scale with input size helps you design efficient cloud solutions and explain your reasoning clearly in interviews.

Self-Check

"What if we batch users and add them in groups of 10 per API call? How would the time complexity change?"