Why we use queue in BFS and stack in DFS? DFS is more memory efficient since it stores number of nodes at max the height of the DFS tree in the stack while BFS stores every adjacent nodes it process in the queue. BFS can be used to find the shortest path, with unit weight edges, from a node ...
READ MORE +








