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
Related videos on Youtube
![troopers97](https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=256)
Author by
troopers97
Updated on July 17, 2022Comments
-
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 about 6 yearsDid you analyzing it yourself? Try calculating what values the algorithm should store, show us your approach.
-