search
Log In
0 votes
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??

in Algorithms 175 views
0
unweighted = take each distance ( edge weight ) = 1 unit.

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

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

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

1 Answer

1 vote
 
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.

selected by

Related questions

0 votes
1 answer
2
460 views
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??
asked May 12, 2019 in Algorithms srestha 460 views
0 votes
1 answer
3
96 views
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??
asked May 10, 2019 in Algorithms srestha 96 views
0 votes
2 answers
4
91 views
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??$
asked May 10, 2019 in Algorithms srestha 91 views
...