Depth-First Search (DFS)
Depth-First Search (DFS) is an algorithm used for traversing or searching through data structures like trees and graphs. It starts at a selected node and explores as far as possible along each branch before backtracking. This method uses a stack, either through recursion or an explicit stack data structure, to keep track of the nodes to visit next.
DFS is particularly useful for problems that require exploring all possible paths, such as solving puzzles or finding connected components in a graph. However, it may not always find the shortest path, making it less suitable for certain applications compared to other algorithms like Breadth-First Search (BFS).