Added code for DFS and BFS