- 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.
- 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.