Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sh2aliyev/notes/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Visits nodes level by level in a graph or tree, starting from the closest nodes to the start point.| Time | Space |
|---|---|
O(n) | O(n) |
Tree BFS
Example Tree:

Implementation
Go to Binary Search Tree for the complete BST implementation.
Binary Search Tree
Graph BFS
Example Graph:

Adjacency Matrix
Graph BFS (adjacency matrix)
Adjacency List
Graph BFS (adjacency list)
Matrix (2D Array) BFS
Example 2D Array:
The red line shows the search flow starting from points

row: 2 and col: 2 (green numbers show the same in a simpler format).Implementation
Matrix BFS