GATE CSE
First time here? Checkout the FAQ!
x
+3 votes
168 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 (6k points)   | 168 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 (45k 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 Mar 2017
  1. rude

    5236 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2732 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1430 Points

  8. Bikram

    1424 Points

  9. Akriti sood

    1416 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,549 questions
26,889 answers
61,246 comments
23,251 users