-1

Give the reasons for the above my query

I find the above questions of the traverse of graph. Bfs and DFS both are the traverse to detect the cycle in a graph but most is the dfs why this is the best to solve the graph of a cycle

0

1 Answer 1

0

1.When I code graph traversals, the dfs stack is easier to implement than a queue.

2.Also we can often use less memory for having one long path and not all in parallel.

3.It depends on your graph to use DFS or BFS. This can optimize a choosen bottleneck and yield better average/minimal/maximal complexity.

Edit: duplicate at Why DFS and not BFS for finding cycle in graphs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.