175 views

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??

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

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

@Shaik Masthan

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??

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

1 vote

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.

selected by

## Related questions

1
494 views
Consider a procedure $find()$ which take array of $n$ ... Here we need to sort first and then need to compare adjacent element right?? Then what will be complexity??
An array $A$ of size n is known to be sorted except for the first $k$ elements and the last $k$ elements, where $k$ is a constant. Which of the following algorithms will be the best choice for sorting the array $A?$ $a)$Insertion Sort $b)$Bubble sort $c)$Quicksort ... ? Quick Sort sorts part by part using pivot. So, why not will it be answer?? How do we know it is asking for almost sorted array??
Consider the following statement: $A)$ If all edge weight of a graph are positive then any subset of edges that connect all vertices and has minimum total weight is a tree. $B)$ Let $p=<V_{0},V_{1},V_{2},........V_{k} >$ be the shortest path ... tree always needed for minimum weight graph?? and what about B)?? Is it just saying each minimum path between $2$ vertices makes total shortest path??
Consider an array $A=\left \{ 30,15,48,34,26,29 \right \}$ Let $X$ be the number of inversion of array $A,$ Now another array $B$ is constructed by making all the numbers in $A$ negative and keeping the order between each numbers same. Let the number of inversion of the modified array so obtained be $Y.$ Then $X+2Y=$_______________ $\left ( 30,26 \right )$ number of inversion $4$ or $1??$