in DS recategorized ago by
135 views
1 vote
1 vote

Which data structure is commonly used to implement breadth first search in a graph?

  1. A queue
  2. A stack
  3. A heap
  4. A hash table
  5. A splay tree
in DS recategorized ago by
by
135 views

1 Answer

1 vote
1 vote
We use queue for Breadth first search because

we need to store the nodes which see from the current node ( neighbouring nodes ) and need to be traversed those nodes in that order ( i.e we visit the nodes in breadth wise manner )

Since Queue is first in first out ( FIFO ) Data structure this will satisfy the requirements that we need
Answer:

Related questions