fix the errors marked by Dr. Brinkman
added a depth first search algorithm