Blob containers and access levels in Azure - Time & Space Complexity
We want to understand how the time to set or check access levels on blob containers changes as the number of containers grows.
How does the number of containers affect the operations needed to manage access?
Analyze the time complexity of the following operation sequence.
// Loop through a list of blob containers
foreach (var container in containers) {
// Set the public access level for each container
container.SetAccessPolicy(PublicAccessType.Blob);
}
This code sets the access level for each blob container in a list to allow public read access to blobs.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: Setting access level on each blob container via API call.
- How many times: Once per container in the list.
Each container requires one API call to set its access level, so the total calls grow directly with the number of containers.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of operations increases linearly as the number of containers increases.
Time Complexity: O(n)
This means the time to set access levels grows directly in proportion to the number of blob containers.
[X] Wrong: "Setting access levels on multiple containers is a single operation regardless of count."
[OK] Correct: Each container requires its own API call, so the total time grows with the number of containers.
Understanding how operations scale with resource count helps you design efficient cloud management scripts and shows you think about real-world system behavior.
"What if we batch set access levels for multiple containers in one API call? How would the time complexity change?"