Tree Traversal
Breadth-First Search (BFS
) and Depth-First Search (DFS
) can both be used to traverse a tree.
The two algorithms run in for both time and space,
where is the number of nodes in the tree.
Breadth-First Search (BFS
) and Depth-First Search (DFS
) can both be used to traverse a tree.
The two algorithms run in for both time and space,
where is the number of nodes in the tree.