
Dijkstra's algorithm time complexity: O((V+E) log V)
Dijkstra's algorithm time complexity: O((V+E) log V)
Dijkstra's algorithm is designed to find the shortest paths in a weighted graph efficiently. The time complexity of O((V+E) log V) indicates that the algorithm's performance scales with the number of vertices (V) and edges (E) in the graph, as well as the efficiency of the priority queue used. This complexity is achieved by using a min-priority queue to repeatedly select the next node with the smallest tentative distance.
Example
In a graph with 5 vertices and 7 edges, Dijkstra's algorithm will perform a series of operations that involve selecting the shortest path from the source node to each of the other nodes. The priority queue helps to efficiently retrieve the next node to process, ensuring that the algorithm completes in O((V+E) log V) time.
Remember this
Understanding the time complexity of Dijkstra's algorithm is crucial for evaluating its efficiency and scalability in real-world applications, such as network routing protocols.
Text adapted from Wikipedia, licensed under CC BY-SA 4.0.
Graph (abstract data type)
Time complexity of BFS and DFS: O(V + E)
Best, worst and average case
Quicksort's average time complexity is O(n log n)
Binary search
How fast can you find a word in a dictionary?
O(n log n) is the lower bound for comparison-based sorting
Ever wonder why sorting can't be faster than a certain point?
merge sort: O(n log n) always
Ever wondered why sorting your music library takes ages?
Hash table
Hash table lookup: O(1) average time complexity
Swipe through 100 ML concepts daily
Open Pocket Polymath