Breadth-First Path Traversal

Algorithm

A breadth-first path-traversal uses a queue in order to remember directories as it scans. Initially, a directory is supplied which is scanned for directories in order to place them in the queue. On every iteration, a directory is pulled off the queue and similarly scanned in order to enqueue any newly found directories. The algorithm terminates when the queue is empty.

  1. Enqueue the first directory.
  2. Dequeue a directory from the queue.
  3. If the dequeued directory contains any directories, then enqueue the directories.
  4. Repeat at 2 until the queue is empty.

Performance and Space Complexity

where $|E|$ is the number of edges and $|V|$ is the number of vertices.

Implementations