What is the space complexity of Dijkstra Algorithm?

10,323

Time and Space for Dijkstra Algorithm:

  • Time: O((|V| + |E|) log V)
  • Space: O(|V| + |E|)

However, (E >= V - 1) so |V| + |E| ==> |E|. But usually we use both V and E

Share:
10,323

Related videos on Youtube

troopers97
Author by

troopers97

Updated on July 17, 2022

Comments

  • troopers97
    troopers97 almost 2 years

    The time complexity for Dijkstra Algorithm using an array is O(V^2) and if priority queue is implemented, we can further improve the complexity to O(E log V). But what about its space complexity? Is it O(V) in both cases?

    • Ivan Smirnov
      Ivan Smirnov about 6 years
      Did you analyzing it yourself? Try calculating what values the algorithm should store, show us your approach.