// Select an algorithm to see its code
Select an algorithm and click visualize to see the explanation of each step.
| Algorithm | Worst-Case Time | Average-Case Time | Best-Case Time | Space Complexity | Description |
|---|---|---|---|---|---|
| Breadth-First Search (BFS) | O(V+E) | O(V+E) | O(V+E) | O(V) | Explores nodes level by level. Uses a queue. |
| Depth-First Search (DFS) | O(V+E) | O(V+E) | O(V+E) | O(V) | Explores deeply before backtracking. Uses a stack (implicitly with recursion). |
| Dijkstra's Algorithm | O(E log V) | O(E log V) | O(E log V) | O(V) | Finds the shortest paths from a single source node to all other nodes in a weighted graph. |
| Bellman-Ford Algorithm | O(V*E) | O(V*E) | O(E) | O(V) | Finds the shortest paths from a single source node to all other nodes in a weighted graph, even with negative edge weights. Detects negative cycles. |
| Floyd-Warshall Algorithm | O(V³) | O(V³) | O(V³) | O(V²) | Finds the shortest paths between all pairs of nodes in a weighted graph, including negative edge weights. |
| Prim's Algorithm | O(E log V) | O(E log V) | O(E) | O(V) | Finds a minimum spanning tree for a weighted undirected graph. Starts with a single node and expands. |
| Kruskal's Algorithm | O(E log E) | O(E log E) | O(E) | O(V) | Finds a minimum spanning tree for a weighted undirected graph. Sorts edges and adds them if they don't create a cycle. |