622 views
closed as a duplicate of: Dijkstra

Which of the following procedure results same output as Dijkstra’s Algo. on unweighted graph on $'n'$ verices?

$A)$ BFS  $B)$ DFS   $C)$Kruskal  $D)$ Prims

As far I know Dijkstra and Prims both have $T.C.=O(E+VlogV)$

But ans given BFS.

How this ans possible??

### 3 Comments

unweighted = take each distance ( edge weight ) = 1 unit.

now think how dijkstra's work and bfs work.. U will realize

@Shaik Masthan

What about Prims??

Dijkstra work on all direction like BFS.

right?? but why not Prims??

Unweighted means no edge weight, then why take each edge weight as 1??

edited by
I think only for unweighted graph we have to select BFS. dijkstra is for weighted graph

## 1 Answer

Best answer
BFS when apply on an unweighted graph , In the resultant BFS tree it can be seen that the shortest path to every vertex from root (or the start vertex) is figured out.

It is quite similar to dijsktra algorithm which is also single source shortest path.

1 vote
1 answer
1
709 views
1 vote
3 answers
2
487 views
0 votes
0 answers
3
65 views
0 votes
0 answers
4
40 views