logo

Crowdly

Browser

Add to Chrome

Recall the algorithm for shortest paths in an unweighted graph. We provide it be...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Recall the algorithm for shortest paths in an unweighted graph. We provide it below, as given in the course notes.

1

2

3

4

5

6

7

8

9

10

11

12

13

function BFS(G = (V, E), s)

dist[1..n] = ∞

pred[1..n] = null

queue = Queue()

queue.push(s)

dist[s] = 0

while queue is not empty do

u = queue.pop()

for each vertex v adjacent to u do

if dist[v] = ∞ then

dist[v] = dist[u] + 1

pred[v] = u

queue.push(v)

Analyse this algorithm and provide:

  • Its worst-case time complexity,
  • Its auxiliary space complexity (excluding the input).

Assume the graph GG is stored as an adjacency matrix. Make no assumption on the edge density of the graph.

Select one worst-case time complexity and one auxiliary space complexity from the list below. Two correct answers and zero incorrect answers are required to pass this question.

0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome