Depth First Search:
- Given a node on a Graphs, explore to the next non-visited node. Label the edge you just took as discovery edge.
- Keep doing this until youâre faced with purely explored paths.For each edge you thatâs explored, label it a back edge
- Backtrack to the most recent step in the path that had a unexplored paths.
- Repeat.
- Eventually, youâll backtrack to A. Thus, youâre finished.
Notes:
- Enabling the labelling stops you from running infinitely.
- Time Complexity:
Breadth First Search:
It selects an arbitrary root node neighbouring nodes first, before moving down to the next level of neighbours. Itâs like âsweepingâ through a maze
Specifically:
- Given every node in level , mark each node thatâs reachable as the next level, level .
- Repeat until thereâs no unexplored nodes.

Time Complexity: