Scenario: 

 Your friend is developing a maze puzzle game and already designed a module that can generate a random maze. 

Scenario:  Your friend is developing a maze puzzle game and already designed a module that can generate a random maze. The maze has one entry and one exit point. Now he needs to develop the module which will find the path from entry to exit points for the randomly generated maze. Your friend wants the path searching should be quickest. He can use only Stack or Queue data structures to store maze’s visited locations for path generation. He is unable to decide the selection of data structure and asked you to help him.

Stack or Queue data structures:
 maze puzzle game:
data structure :

Stack or Queue data structures:  maze puzzle game: data structure :


Solution:

we prefer Stack data structure over Queue because solving maze game problems we need all possible paths and track the path visited.
so, due to less time consumption and efficiency that is possible by stack
In Stack, while moving into the maze, we can push the index of the last visited cell and when reached the end of the maze, just keep popping elements from the stack until the cell at stack has another way to move.
When we use Queue, then when we finding an unsuccessful path, we start again from the entry point because Queue only supports deletion from the front First-In-First-Out property.
Queue produces more time.
So, using stack we find the correct path in the shortest time.


                             Thank You