Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dijkstra's algorithm Vs Uniform Cost Search (Time comlexity)

Tags:

dijkstra

ucs

My question is as follows: According to different sources, Dijkstra's algorithm is nothing but a variant of Uniform Cost Search. We know that Dijkstra's algorithm finds the shortest path between a source and all destinations ( single-source ). However, we can always modify Dijkstra to find the the shortest path between a START and a GOAL state ( when the goal is popped from the priority queue, we simply stop); but doing so, the worst case scenario will be still finding the shortest path from START to all other nodes ( suppose the goal is the furthest node in the graph).

If we implement Dijkstra's algorithm using a min-priority heap, the running time will be O(V log V +E) , where E is the number of edges and V the number of vertices.

Since Uniform Cost Search is the same as Dijkstra ( slightly different implementation), then the running time of UCS should be similar to Dijkstra, right? However, according to my AI class, Uniform Cost Search is exponential at the worst case, and it takes O(b1 + [C*/ε]), where C* is the cost of the optimal solution. ( b is the branching factor)

How can both algorithms be the same while they have different running times? Is the running time the same, but the way we look at it is different?

I would appreciate your help :):) Thank you

like image 850
John Avatar asked Oct 19 '12 14:10

John


1 Answers

Is the running time the same, but the way we look at it is different?

Yes. Uniform cost search can be used on infinitely large graphs, on which Dijkstra's original algorithm would never terminate. In such situations, it's no use defining complexity in terms of V and E as both might be infinite and the resulting big-O figure meaningless.

like image 91
Fred Foo Avatar answered Oct 04 '22 14:10

Fred Foo