Back to the 2022 paper

Module 3: Graph and Tree Algorithms

20222m

BFS on a graph G=(V,E)G = (V, E) has running time
(i) O(∣V∣+∣E∣)O(|V| + |E|)
(ii) O(∣V∣)O(|V|)
(iii) O(∣E∣)O(|E|)
(iv) None of these

Worked SolutionAI Assisted

Answer: (i) O(|V|+|E|)

BFS visits each vertex and edge once using adjacency list.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.