Made improvements to DFS and BFS by allowing them to be used as
traversal algorithms.