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.
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
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.