;initial state frontier ← state ;initial frontier while frontier contains incomplete paths and beamwidth > 0 extended frontier ← for each state ∈ frontier do y ← DECODE(state) for each word i ∈ Vocabulary do successor ← NEWSTATE(state, i, y i ) new agenda ← ADDTOBEAM(successor, extended frontier, beam width)