9. 19
Properties of greedy best-first
search
• Complete? No – can get stuck in loops,
– e.g., Iasi Neamt Iasi Neamt
• Time? O(bm), but a good heuristic can give dramatic
Improvement
• Space? O(bm) -- keeps all nodes in memory
• Optimal? No
18. Uniform-cost orders by path cost, or backward
cost g(n)
Greedy orders by goal proximity, or forward
cost h(n)
A* Search orders by the sum: f(n) = g(n) + h(n)
19. Initialize : set open={s} , closed={ }
g(s)=0 , f(s)= h(s)
Fail: if open= { } , terminate and fail
Select: select minimum cost state n from open{ } .save in closed{ }
Terminate: if n belongs to G ,terminate with success , return f(n)
Expand: for each successor m of n
if m Є [open U Closed]
set g(m)=g(n)+c(n,m)
set f(m)=g(m)+h(m)
insert m in open { }
if m Є [open U Closed]
set g(m)=min { g(m), g(n)+c(n,m)}
set f(m)=g(m)+h(m)
If f(m) has decreased and m Є closed
Move m to open { }
A* Algorithm