in DS recategorized by
1,399 views
1 vote
1 vote

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
in DS recategorized by
by
1.4k views

1 comment

Option B
1
1

2 Answers

1 vote
1 vote

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.

0 votes
0 votes

(B) Queue - BFS and Stack -DFS

Answer:

Related questions