0
$\begingroup$

As, we use FIFO(First In First Out) queue in breadth search algorithm but in depth first search we use LIFO.Why we use LIFO instead of FIFO in depth first search?

$\endgroup$
  • $\begingroup$ The question is about the right usage of a stack in which elements of a tree put by an algorithm. The nodes of the graph are numbered, put in some order to the queue and then are requested. What exactly is the relationship to Artificial Intelligence? Is it perhaps a pathfinding algorithm for a robot? $\endgroup$ – Manuel Rodriguez Nov 26 '18 at 16:58
0
$\begingroup$

We use LIFO queue i-e stack for implementation of depth first search algorithm because depth first search always expands the deepest node in the current frontier of the search tree.The search proceeds immediately to the deepest level of the search tree, where the nodes have no successors.As those nodes are expanded, they are dropped from the frontier, so then the search "backs up" to the next deepest node that still has unexplored sucessors. A LIFO queue means that the most recently generated node is chosen for expansion. This must be the deepest unexpanded node because it is one deeper than its parent___ which, in turn, was the deepest unexpanded node when it was selected.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.