GATE CSE
First time here? Checkout the FAQ!
x
+3 votes
232 views
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)?
asked in Algorithms by Boss (6.1k points)   | 232 views

1 Answer

+4 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 )$
answered by Veteran (47.6k points)  
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).


Top Users Jul 2017
  1. Bikram

    4386 Points

  2. manu00x

    2464 Points

  3. Debashish Deka

    1850 Points

  4. joshi_nitish

    1686 Points

  5. Arjun

    1340 Points

  6. Hemant Parihar

    1184 Points

  7. Arnab Bhadra

    1112 Points

  8. Shubhanshu

    1080 Points

  9. Ahwan

    900 Points

  10. rahul sharma 5

    732 Points


24,031 questions
30,983 answers
70,430 comments
29,358 users