Shortest Path in an Undirected, Unweighted Graph
Given a graph where users are vertices and their connections are undirected edges, find the shortest connection distance between two users. As a follow-up, analyze scalability for millions of users and implement a bi-directional BFS to improve upon the traditional BFS solution.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early December, 2026
A user represents a Vertex and the connections represents the undirected edge. I needed to find the shortest connection distance between two users. A follow-up question: 1. What if we have a Million members. How does the current solution scale? What are the potential options to improve upon the BFS solution? 2. Implement Bi-directional BFS and explain how it improves upon traditional BFS
Hello Interview Premium
Your account is free and you can post anonymously if you choose.