Question: is depth first search optimal?
Answer: BFS is good to use when the depth of the tree can vary or if a single answer is needed—for example, the shortest path in a tree. If the entire tree should be traversed, DFS is a better option. BFS always returns an optimal answer, but this is not guaranteed for DFS.