My book here (Artificial intelligence A modern approach) says that the worst-case time and space complexity of a uniform-cost search algorithm would be O(b[C*/e]) , where b is the branching factor, C* is the cost of the optimal solution, and every action costs atleast e. But why is this so?
My book here (Artificial intelligence A modern approach) says that the worst-case time and
Share
First, the complexity is
O(B^(C/e))[exponential inC/e].To understand it, think of a simple example case first:
Let
G=(V,E)be a graph, with branch factorB. The graph is unweighted (w(e) = 1for eache).Consider finding the shortest path from S to T.
In this case, the algorithm is actually a BFS, and it will discover all nodes in the path up to length
SOL, whereSOLis the length of the shortest path, which isO(B^|SOL|)For the general case – the same idea holds, you need to discover all nodes up to cost
C. So you discover nodes up to depthC/e, giving youO(B^(C/e))total nodes needed to be explored.The exponential factor is because: First level (root) has
B^0=1nodes, second level has B nodes. from each of these you discoverBnodes, giving youB^2, ….EDIT:
Missed it so far, but the title asks for space complexity and not time complexity. However, the answer remains the same, since a uniform cost search holds a
visitedset, for already visited nodes. Since each node you discover is also added to it – the answer remainsO(B^(C/e))