There are two core graph exploring algorithms breadth-first search and depth-first search. Assuming that you already familiar with BFS, so – in this topic I’m going to compare these two algorithms and also I will provide my version of **DFS**.

The algorithm requires some initial point which will be used as a starting point, from which traversing/searching will go on. Here is a graph and let vertix “A” be a starting point.

From vertex “A” it goes as far as it possible until it reaches the leaf or it self. Once the vertex that has no successors is reached, it gets back. On the way back, if it meets nodes that were not visited then it traverses them in same way. Visually, the path can be represented as level. Thus, it explores first level, then second and so on. Continue reading Depth-First Search (DFS)