Making GET and POST requests in No-Code - Time & Space Complexity
When we make GET or POST requests, the time it takes depends on how many requests we send and how the server handles them.
We want to understand how the total time grows as we increase the number of requests.
Analyze the time complexity of the following code snippet.
for each item in list:
send GET request to server
wait for response
process response
This code sends a GET request for each item in a list, waits for the server to respond, then processes the response.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Sending a GET request and waiting for its response.
- How many times: Once for each item in the list.
As the number of items grows, the total time grows roughly in the same way because each item causes one request.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 requests and responses |
| 100 | 100 requests and responses |
| 1000 | 1000 requests and responses |
Pattern observation: The total time grows directly with the number of requests.
Time Complexity: O(n)
This means the time grows in a straight line as you add more requests.
[X] Wrong: "Sending multiple requests at once will always take the same time as sending one."
[OK] Correct: Each request takes time, so more requests usually mean more total time, even if some happen at the same time.
Understanding how request time grows helps you design better apps and explain your thinking clearly in interviews.
"What if we send all requests at the same time without waiting for each response? How would the time complexity change?"