bfs dfs algorithm with example