GATE CSE
First time here? Checkout the FAQ!
x
+3 votes
279 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)   | 279 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.9k 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 Sep 2017
  1. Habibkhan

    8796 Points

  2. rishu_darkshadow

    3566 Points

  3. Warrior

    2914 Points

  4. Arjun

    2840 Points

  5. A_i_$_h

    2550 Points

  6. manu00x

    2268 Points

  7. nikunj

    1990 Points

  8. Bikram

    1874 Points

  9. makhdoom ghaya

    1820 Points

  10. SiddharthMahapatra

    1718 Points


26,346 questions
33,926 answers
80,524 comments
31,232 users