Implement DFS and BFS instance methods