How Google ranks pages (ranking) in SEO Fundamentals - Performance & Efficiency
When Google ranks pages, it processes many factors to decide which pages show up first.
We want to understand how the time to rank pages grows as the number of pages increases.
Analyze the time complexity of this simplified ranking process.
// For each page in the index
for each page in pages:
score = 0
// Check links from other pages
for each other_page in pages:
if other_page links to page:
score += other_page.rank / number_of_links
page.rank = calculate_final_score(score)
This code calculates a score for each page based on links from all other pages.
- Primary operation: Nested loops checking links between pages.
- How many times: For each page, it checks every other page, so roughly n x n times.
As the number of pages grows, the work grows much faster.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 100 checks |
| 100 | 10,000 checks |
| 1000 | 1,000,000 checks |
Pattern observation: Doubling pages roughly quadruples the work because of the nested checks.
Time Complexity: O(n²)
This means the time to rank pages grows roughly with the square of the number of pages.
[X] Wrong: "Ranking time grows linearly as pages increase."
[OK] Correct: Because each page's score depends on all other pages, the work grows much faster than just adding pages.
Understanding how ranking scales helps you think about handling large data efficiently, a key skill in many roles.
What if we stored link counts in a map to avoid checking every page? How would the time complexity change?