Log In
5 votes
What is the time complexity of Dijkstra’s algorithm if it is implemented using AVL Tree instead of Priority Queue over a graph G = (V, E)?
in Algorithms 1.2k views

1 Answer

15 votes
Best answer
Dijkstra running time complexity is =>

$O\left ( E . T_{dk} + V . T_{em} \right )$

where $T_{dk}$ and $T_{em}$ are the decrease key and extract minimum operations of vertex set Q respectively.

For AVL tree, all the operations are $O\left ( Log V \right )$

Hence, Time complexity to run dijkstra becomes =>

=> $O\left ( E.|Log V| + V . | Log V| \right )$

selected by
How the decrease  key  is of order O(logV)?
I understood for extract-min we have to extract the left most node which can be extracted in logv time easily.
If a pointer is given 2 that key which we want 2 decrease then first decrease that key in O(1) time after that adjust that key in AVL tree so that it does not voilate the property (left node is equal or less than this and right is greater than this) it will take at max O(logv) time
hence overall time complexity is O(logv)
if pointer is not given then first search that particular key in logv time ... anthen apply decrease key operation it will also take same time complexity as above.(logv)
@Vaishali, Not only decrease key operation. AVL tree guarantees everything in O(Log N).

If we take Fibonacci heap, It also guarantees in O(Log N), but Decrease key and insertion can be done in O(1).

Related questions

1 vote
1 answer
When the graph contain negetive weight edges but no negetive weight cycle, in this case can dijkstra leads to incorrect result?
asked Nov 4, 2016 in Algorithms vaishali jhalani 405 views
1 vote
1 answer
15 votes
1 answer
For the graph given below Dijkstra’s algorithm does not provide correct shortest path tree. Suppose a new graph that is different only in weight between Q to S is created. The number of values of edge [Q to S] that ensures that Dijkstra’s provide the correct shortest path tree where the values of edge (Q to S) ∈ [–20, 20] and ‘P’ is the source vertex are ______.
asked Sep 24, 2016 in Algorithms User007 1.1k views