Depth First Search algorithm is an algorithm to search node from tree or graph. DFS algorithm starts traversing from the root. It traverses each branch before backtracking. DFS takes less memory compared than Breadth first search and not necessary to store all of the child pointers at each level.

Breadth First Search is an algorithm for searching the nodes in tree or graph data structures. It starts from the root node and explores the neighbor nodes first, before moving to the next level neighbors. If the solution is not far from the root, we can choose breadth-first search solution. If the solutions are far, it takes a lot of time to find the solution.

A graph data structure consists of a finite (and possibly mutable) set of nodes or vertices. A graph may be either undirected or directedGraph supports add, delete, neighbors, adjacent operations.