closed by
3,335 views
1 1 vote
closed with the note: resolved

Question Source - https://gateoverflow.in/1374/gate2005-38

Let G(V,E)be an undirected graph with positive edge weights. Dijkstra’s single source shortest path algorithm can be implemented using the binary heap data structure with time complexity:

 1. O(|V|2)
 2. O(|E|+|V|log|V|)
 3. O(|V|log|V|)
 4. O((|E|+|V|)log|V|)

========================================================================

Correct answer is -  

> 4. O((|E|+|V|)log|V|)

=========================================================================

My Approach is as follows - 

O(V+V+VlogV+ElogV) = O(ElogV)

 - O(V) to initialize.
 - O(V) to Build Heap.
 - VlogV to perform Extract_Min
 - ElogV to perform Decrease Key

> Now, as I get O(ElogV) and when I see options, a part of me says the
> correct one is O(VlogV) because for a sparse Graph |V| = |E|, but as I
> said the correct answer is O((|E|+|V|)log|V|). So, where am I going
> wrong?

1 Answer

Best answer
2 2 votes

correct one is O(VlogV) because for a sparse Graph |V| = |E|

Who said it is a Sparse Graph? Question doesn't say that. What if It were a Dense Graph?  

selected by
Position:
Show:

Related questions

0 0 votes
2 answers 2 answers
1.9k
1.9k views
Bikram asked May 26, 2017
1,935 views
What will be the running-time of Dijkstra's single source shortest path algorithm, if the graph $G(V,E)$ is stored in the form of an adjacency list and binary heap is use...
11 11 votes
5 answers 5 answers
6.0k
6.0k views
Vikrant Singh asked Dec 28, 2014
5,980 views
What is the complexity of finding $50^{th}$ smallest element in an already constructed binary min-heap?$\Theta(1)$$\Theta (\log n)$$\Theta (n)$$\Theta (n \log n)$
1 1 vote
0 0 answers
914
914 views
rahul sharma 5 asked Dec 10, 2016
914 views
From Wikipedia :the algorithm requirestime in the worst case;for connected graphs this time bound can be simplified to 1. Can somebody explain how are we combing (V+E) in...
0 0 votes
1 1 answer
464
464 views
Neeraj_patel asked Nov 14, 2024
464 views
What is the Time Complexity of the Dijkstra when it is using Adjacency list + Array (sorted or unsorted ) ? If it is O( V^2 + E ) then ,According to the General form of A...