0
0
Rest APIprogramming~5 mins

Postman collection organization in Rest API - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Postman collection organization
O(n)
Understanding Time Complexity

When organizing Postman collections, it's important to understand how the time to find or run requests grows as the collection gets bigger.

We want to know how the effort changes when we add more requests or folders.

Scenario Under Consideration

Analyze the time complexity of searching for a request in a Postman collection organized with folders and requests.


// Pseudocode for searching a request by name in a Postman collection
function findRequest(collection, name) {
  for (const folder of collection.folders) {
    for (const request of folder.requests) {
      if (request.name === name) {
        return request;
      }
    }
  }
  return null;
}
    

This code looks through each folder and each request inside to find a request by its name.

Identify Repeating Operations

Look for loops or repeated steps in the code.

  • Primary operation: Looping through all folders and then all requests inside each folder.
  • How many times: The inner loop runs once for each request in every folder, so total requests count.
How Execution Grows With Input

As the number of folders and requests grows, the search takes longer.

Input Size (total requests)Approx. Operations
1010 checks
100100 checks
10001000 checks

Pattern observation: The time grows directly with the number of requests; doubling requests doubles the work.

Final Time Complexity

Time Complexity: O(n)

This means the time to find a request grows in a straight line with the number of requests in the collection.

Common Mistake

[X] Wrong: "Adding folders makes searching faster because it narrows down the search."

[OK] Correct: Even with folders, if you have to check every request inside, the total work depends on all requests, so folders alone don't reduce search time.

Interview Connect

Understanding how organizing API requests affects search time helps you design better tools and workflows, a useful skill in many software roles.

Self-Check

"What if we added an index or map from request names to requests? How would the time complexity change?"