Pages and reusable elements in No-Code - Time & Space Complexity
When working with pages and reusable elements, it is important to understand how the time to load or update them changes as the number of elements grows.
We want to know how the work needed grows when we add more pages or reusable parts.
Analyze the time complexity of the following process.
For each page in the app:
Load the page content
For each reusable element on the page:
Load the reusable element content
This describes loading multiple pages where each page contains several reusable elements that also need loading.
Look at what repeats in this process.
- Primary operation: Loading each reusable element on every page.
- How many times: For each page, all its reusable elements are loaded, so the loading repeats for every element on every page.
As you add more pages or more reusable elements per page, the total loading work grows.
| Input Size (pages x elements) | Approx. Operations |
|---|---|
| 10 pages x 5 elements | 50 loads |
| 100 pages x 5 elements | 500 loads |
| 100 pages x 50 elements | 5,000 loads |
Pattern observation: The total work grows proportionally to the number of pages times the number of reusable elements per page.
Time Complexity: O(p x e)
This means the time to load grows in direct proportion to the number of pages (p) multiplied by the number of reusable elements (e) on each page.
[X] Wrong: "Loading reusable elements once means loading time stays the same no matter how many pages use them."
[OK] Correct: Even if elements are reused, they must be loaded for each page they appear on, so total loading time increases with more pages.
Understanding how loading time grows with pages and reusable elements helps you design efficient apps and explain your reasoning clearly in discussions.
"What if reusable elements were cached after the first load? How would that change the time complexity?"