recategorized by
1,391 views
1 votes
1 votes

What are the appropriate data structures for graph traversal using Breadth First Search(BFS) and Depth First Search(DFS) algorithms?

  1. Stack for BFS and Queue for DFS
  2. Queue for BFS and Stack for DFS
  3. Stack for BFS and Stack for DFS
  4. Queue for BFS and Queue for DFS
recategorized by

2 Answers

1 votes
1 votes

BFS stands for Breadth First Search is a vertex based technique for finding a shortest path in graph. It uses a Queue data structure which follows first in first out. In BFS, one vertex is selected at a time when it is visited and marked then its adjacent are visited and stored in the queue.

 

DFS stands for Depth First Search is a edge based technique. It uses the Stack data structure, performs two stages, first visited vertices are pushed into stack and second if there is no vertices then visited vertices are popped.

Answer:

Related questions

0 votes
0 votes
1 answer
1
admin asked Mar 30, 2020
883 views
In a given following graph among the following sequences: abeghf abfehgabfhgeafghbe Which are depth first traversals of the above graph?I,II and IV onlyI and IV onlyII,II...