Implemented DFS and BFS search