A depth-first search is a kind of algorithm which searches graph or tree data structures. It starts at the root node and searches as far as possible along every branch before it performs backtracking. It is based on LIFO. And the order of nodes in DFS algorithms is different from that of BFS algorithms. The system stores the path in every iteration linearly and requires space for the same.