# How Many Steps Apart? Breadth-First Search

Find how many friendships apart two people are, the fewest, without listing every route or walking in circles: why both of those fail, and the search that fixes them, breadth-first search, with a queue and a visited set.

![Cheat sheet: How Many Steps Apart? Breadth-First Search](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/026379189fa54d3db8ca233d7ff1601a.webp)

- Category: Data Structures
- Level: Journeyman
- Tags: Breadth-First Search, data structures, Graph, Shortest Path, Vertex
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/ds-bfs-cheat-sheet
