Depth-first search:
dfs, using recursive functions, search through the stack structure.
template:
BFS:
bfs, using recursive functions, search the way through the queue.
dfs is a search for a tree, through a certain sequence to each of the sub-branches of the tree traversal all over again. . It is similar from the starting point, first of all point in one direction will change direction traversed ...... "do not hit the brick wall does not look back."
bfs is traversing a certain depth, kept up by way of a queue, push side edge pop, known traversed until the queue is empty. bfs relative dfs for more use of space. DFS is a space-efficient, DFS no need to save the state of the search process, in BFS search process and the need to save the state searched, and generally require a queue record.