started refactoring algorithm base class and added depth first algorithm.