Broken link building in SEO Fundamentals - Time & Space Complexity
When working with broken link building, it's important to understand how the effort grows as the number of links to check increases.
We want to know how the time needed to find and fix broken links changes when we look at more web pages.
Analyze the time complexity of the following SEO process snippet.
// Pseudocode for broken link building process
for each page in website_pages:
for each link in page.links:
if link is broken:
record broken link
reach out to webmaster
This code checks every link on every page to find broken ones and then contacts the site owner to suggest a fix.
Look at what repeats as the input grows.
- Primary operation: Checking each link on every page.
- How many times: For every page, all its links are checked one by one.
As the number of pages and links grows, the total checks increase quickly.
| Input Size (pages x links) | Approx. Operations |
|---|---|
| 10 pages x 5 links | 50 link checks |
| 100 pages x 5 links | 500 link checks |
| 1000 pages x 5 links | 5000 link checks |
Pattern observation: The total work grows proportionally with the number of pages times the number of links per page.
Time Complexity: O(n * m)
This means the time needed grows in direct proportion to the number of pages (n) multiplied by the number of links per page (m).
[X] Wrong: "Checking broken links takes the same time no matter how many pages or links there are."
[OK] Correct: More pages and links mean more checks, so the time grows with the total number of links, not stays fixed.
Understanding how the effort scales with input size helps you plan SEO tasks and explain your approach clearly in discussions.
What if we only checked a sample of links per page instead of all? How would the time complexity change?