Online model repositories (Thingiverse, Printables) in 3D Printing - Time & Space Complexity
When using online model repositories like Thingiverse or Printables, it's important to understand how the time to find and download models changes as the number of available models grows.
We want to know how the effort or waiting time increases when the repository gets bigger.
Analyze the time complexity of searching for a model in an online repository.
function searchModels(models, keyword) {
let results = [];
for (let model of models) {
if (model.title.includes(keyword) || model.tags.includes(keyword)) {
results.push(model);
}
}
return results;
}
This code looks through each model to find those matching a keyword in the title or tags.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Checking each model one by one in the list.
- How many times: Once for every model in the repository.
As the number of models grows, the search checks more items, so the time grows steadily.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: The time to search grows directly with the number of models.
Time Complexity: O(n)
This means the search time increases in a straight line as the number of models increases.
[X] Wrong: "Searching a model is always instant no matter how many models there are."
[OK] Correct: Because the search checks each model one by one, more models mean more checks and longer search time.
Understanding how search time grows with data size helps you explain how apps handle large collections efficiently, a useful skill in many tech roles.
"What if the repository used an index to find models instead of checking each one? How would the time complexity change?"