BFS and DFS implemented