Pages

Friday, April 13, 2012

Which data structure would you use when traversing a graph using DFS ?

The simple way to implement depth first search is using a "stack". So my answer is "stack" . When ever you are using Depth first search ( DFS ) then use of "Stack" data structure is good.

If you have any other answers apart for this then you can comment but must specify the justification of you answer.

Which data structure would you use when traversing a graph using BFS ?

The simple way to implement breadth first search is using a "queue". So my answer is "queue" . When ever you are using Breadth first search ( BFS ) then use of "queue" data structure is good.

If you have any other answers apart for this then you can comment but must specify the justification of you answer.