edited by
1,331 views

1 Answer

0 votes
0 votes

DFS or Depth-First Search takes less memory than BFS and Linear Search.

BFS uses a queue, which contains nodes at the front of the search. So at most all nodes at distance d.

whereas, DFS uses a stack, which contains nodes from root to the node being searched. So at most the radius of the graph.

If we consider a balanced k-ary tree and the depth of the tree is $O(log(n))$ and at the lowest level there are $O(n)$ nodes , then

DFS uses $O(log(n))$ memory while BFS uses $O(n)$ memory.

edited by

Related questions

1 votes
1 votes
2 answers
1
gatecse asked Mar 2, 2018
2,320 views
Which of the following problem cannot be solved without recursion?Tower of HanoiFibonacci seriesTree TraversalNone of the above
0 votes
0 votes
1 answer
2
gatecse asked Mar 2, 2018
345 views
If there is a graph such that there is a unique path between any pair of vertices. The graph is a ________MeshGridTreeBipartite graph
0 votes
0 votes
1 answer
3
gatecse asked Mar 2, 2018
6,002 views
Which of the following is not used for hash function?Mid-square methodDivision methodFolding methodProbe method
0 votes
0 votes
2 answers
4
gatecse asked Mar 2, 2018
452 views
If the post order traversal of treegives $ab - cd * +$, then the label of the nodes A, B, C, ......, G will bea, -, b, +, c, *, d+, -, *, a, b, c, d-, a, +, b, c, d, *a, ...