DSAOps Lab
D
DSAOps LabRecommendation Lab

Meta

Recommendation Lab

Friend recommendation, feed ranking, trending algorithm, product recommendation

Walkthrough

How Meta Recommendations Work

Step-by-step from social graph to personalized feed

1

Users & Social Graph

Meta's social graph connects users through friendships, follows, and interactions. Each node is a user, each edge represents a relationship. This graph has billions of nodes and trillions of edges.

You
A
B
C
D
1 / 5

Algorithms

Social Graph · Click a node
YYouAAliceBBobCCarolDDaveEEveFFrank

Log

Interact with the simulation

Algorithm

BFS traverses the social graph level by level.

Start → direct friends → their unvisited neighbors = recommendations.

Complexity

BFS
O(V+E)/O(V)
Priority Queue
O(N log N)/O(N)
Heap Sort
O(N log N)/O(1)
Similarity
O(N log N)/O(N)

Interview Qs

Q

Design friend recommendation for 2B users.

H:

Graph partitioning, BFS with depth limit, ANN search.

Q

Rank a feed with 1000+ signals per post.

H:

ML ranker + priority queue. Consider fairness & diversity.

Q

Design real-time trending topics.

H:

Sliding window + max-heap per time bucket. Shard by geography.

Q

Build e-commerce product recommendation.

H:

Collaborative + content-based filtering. Matrix factorization.