Skip to content

front / back / next_front [terminology]

Terminology

Usage

  • Use for bidirectional search frontiers.
  • front and back represent the active layers growing from opposite ends.
  • next_front stores the following BFS layer.
  • Do not use l and r, because these values are sets rather than pointers.
front = {beginWord}
back = {endWord}
# ...
while front:
    # ...
    next_front = set()
    # ...
    front = next_front

See 127. Word Ladder.