Step 1: Understand what DFS (Depth-First Search) is. It is an algorithm used to explore nodes and edges of a graph.
Step 2: Identify the components of a graph. A graph consists of vertices (V) and edges (E). Vertices are the points, and edges are the connections between them.
Step 3: Realize that during the DFS process, each vertex is visited once. This means we will count each vertex in our time complexity.
Step 4: Understand that DFS also explores each edge in the graph. Each edge is considered once when traversing from one vertex to another.
Step 5: Combine the visits to vertices and edges. Since we visit each vertex (V) and each edge (E) once, we add them together.
Step 6: Conclude that the worst-case time complexity of DFS is O(V + E), which means it scales with the number of vertices and edges in the graph.