Explanation of runtimes of BFS and DFS
Why are the running times of BFS and DFS O(V+E), especially when there is a node that has a directed edge to a node that can be reached from the vertex, like in this example in the following site http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/GraphAlgor/depthSearch.htm E is the set of all edges in the graph, as G={V,E}. So, |E| is count of all edges in the graph. This alone should be enough to convince you that the overall complexity can't be |V| times |E|, since we are not iterating over all the edges in the graph for each vertex. In the adjacency list representation, for each