Group Web Pages Into Mutually Reachable Link Clusters
Last updated: November 29, 2026
Quick Overview
Given a directed graph of web pages and hyperlinks, partition the pages into strongly connected components, where every page in a group can reach every other page in that group by following links.
0
0
0 solved
Given a directed graph of web pages and hyperlinks, partition the pages into strongly connected components, where every page in a group can reach every other page in that group by following links.
An onsite question rooted in web graph analysis, where SCCs reveal link farms and the bow-tie structure of the web that matters to crawling and ranking at Google. The interviewer wants Kosaraju or Tarjan implemented correctly and iteratively, plus a clear explanation of why it works.
What the Interviewer Expects
- Define strongly connected components precisely
- Implement Kosaraju (two passes) or Tarjan (one pass with low-links)
- Make DFS iterative for graphs with long chains
- Explain why finishing order on the reverse graph isolates components
- Mention the condensation DAG and its uses
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Build the condensation DAG and find its source components.
- How would you compute SCCs on a web graph with billions of edges?
- Use SCCs to detect link farms for spam filtering.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input:
npages,linksas directed pairs. - Output: list of components, each a sorted list of pages.
- Graph can be large with long chains, so recursion is a risk in Python....
High-Level Design
Kosaraju's algorithm: (1) DFS the original graph and record nodes in order of finishing time. (2) Process nodes in reverse finishing order on the transposed graph; each DFS in this pass collects exact...