sügavusotsingu
sügavusotsingu, often translated as depth-first search (DFS), is an algorithm for traversing or searching tree or graph data structures. It begins at the root node (or an arbitrary node in the case of a graph) and explores as far as possible along each branch before backtracking. The algorithm prioritizes going deeper into the structure before exploring other branches.
In a tree, DFS systematically visits each node. It moves down a path until it reaches a
When using recursion, the function calls itself for each unvisited neighbor of the current node. With a
DFS is particularly useful for problems where the solution is expected to be found deep within the