GATE CSE
First time here? Checkout the FAQ!
x
+3 votes
206 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)   | 206 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.2k 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 May 2017
  1. akash.dinkar12

    3338 Points

  2. pawan kumarln

    2108 Points

  3. Bikram

    1922 Points

  4. sh!va

    1682 Points

  5. Arjun

    1614 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1208 Points

  8. Angkit

    1056 Points

  9. LeenSharma

    1018 Points

  10. Arnab Bhadra

    812 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    1008 Points

  2. pawan kumarln

    734 Points

  3. Arnab Bhadra

    726 Points

  4. Arjun

    342 Points

  5. bharti

    328 Points


22,893 questions
29,196 answers
65,302 comments
27,695 users