I am trying to convert this recursive algorithm in an iterative one, it is the ida A* algorithm (from wikipedia). I have implemented it and the iterative version doesn't return the same result as the recursive version.
function search(node, bound)
if state.f > bound then return state.f
if is_goal(node) then return FOUND
min := ∞
for succ in successors(node) do
t := search(succ, bound)
if t = FOUND then return FOUND
if t < min then min := t
end for
return min
end function
First attempt
function search(node, bound)
stack = new Stack()
stack.push(node)
while(!stack.empty())
state = stack.pop()
min := ∞
if state.f > bound then
if state.f < min then min := state.f
continue
if is_goal(node) then return FOUND
for succ in successors(node) do
stack.push(succ)
end for
return min
end function