BFS and DFS (iteration and recursive) solution