Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 1.02 KB

File metadata and controls

15 lines (12 loc) · 1.02 KB

Breadth-First-Search (BFS)

Search algorithm used to traverse or serach through a graph. Start from a grpah vertex, and traverse all this vertext's neighboor nodes first, then move to next level.

Implement Keys

  • For graph, we need to maintain a visited array to record which node is visited.
  • For BFS, we use queue. The FIFO data structure promise to traverse all nodes in the higher level before go to next level.
  • source code (I used my own queue, but in face we can just use JavaScript's array to simulate a queue, use shift to dequeue, push to enqueue).

Questions

Resource