Skip to content

Files

Latest commit

a822cbe · May 17, 2022

History

History
13 lines (9 loc) · 455 Bytes

File metadata and controls

13 lines (9 loc) · 455 Bytes

Graph

Breadth First Search (BFS)

  • Use the queue data structure to hold each vertex that needs to be visited in the future.
  • It should keep a visited data structure to store all the visited vertices.
  • Runtime: O(V+E) / V = vertices | E = edges.

Depth First Search (DFS)

  • Use the stack data structure or do recursive.
  • It should keep a visited data structure to store all the visited vertices.
  • Runtime: O(V+E) / V = vertices | E = edges.