4 Depth First Search

function dfs(P = ⟨S, s₀, A, τ, c, G⟩):
    agenda ← newStack()
    agenda.push(s₀)
    while not agenda.isEmpty():
        s ← agenda.pop()              # expand s
        for a ∈ A:
            s' ← τ(s, a)
            if s' ∈ G:                # goal found?
                return "done"
            agenda.push(s')           # goal not found, add s' to stack

Evaluation