[Breadth-first search run-time complexity: adjacency matrix] Analyze the run-time of the following BFS algorithm when the graph is represented as an adjacency matrix (instead of adjacency list). State the run-time complexity using a big-O notation and write the steps of its derivation. Please explain your steps. Will leave review BFS (s) : Set Discovered[s] = true and Discovered[u] = false for all other u Initialize L[0] to consist of the single element s Set the layer counter i=0 Set the current BFS tree T= Ø While L[i] is not empty Initialize an empty list L[i+1] For each node u E L[i] Consider each edge (u, v) incident to u If Discovered[v] = false then Set Discovered[v] = true Add edge (u,v) to the tree T Add v to the list L[i+1] Endif Endfor Increment the layer counter i by one Endwhile
[Breadth-first search run-time complexity: adjacency matrix] Analyze the run-time of the following BFS
Please explain your steps. Will leave review
BFS (s) :
Set Discovered[s] = true and Discovered[u] = false for all other u
Initialize L[0] to consist of the single element s
Set the layer counter i=0
Set the current BFS tree T= Ø
While L[i] is not empty
Initialize an empty list L[i+1]
For each node u E L[i]
Consider each edge (u, v) incident to u
If Discovered[v] = false then
Set Discovered[v] = true
Add edge (u,v) to the tree T
Add v to the list L[i+1]
Endif
Endfor
Increment the layer counter i by one
Endwhile
Step by step
Solved in 3 steps