COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
O(e)
|
|
O(v*e)
|
|
O(v + e)
|
|
O(v)
|
Detailed explanation-1: -Explanation: The Breadth First Search explores every node once and every edge once (in worst case), so it’s time complexity is O(V + E).
Detailed explanation-2: -The time complexity of DFS if the entire tree is traversed is O ( V ) O(V) O(V) where V is the number of nodes. In the case of a graph, the time complexity is O ( V + E ) O(V + E) O(V+E) where V is the number of vertexes and E is the number of edges.
Detailed explanation-3: -The time complexity of BFS algorithm is O(V+E), since in the worst case, BFS algorithm explores every node and edge. In a graph, the number of vertices is O(V), whereas the number of edges is O(E). The space complexity of BFS can be expressed as O(V), where V is the number of vertices.
Detailed explanation-4: -Complexity. The time complexity of DFS is O(V + E) where V is the number of vertices and E is the number of edges. This is because in the worst case, the algorithm explores each vertex and edge exactly once.
Detailed explanation-5: -Time Complexity of BFS = O(V+E) where V is vertices and E is edges. Time Complexity of DFS is also O(V+E) where V is vertices and E is edges.