Dovetailing (computer science)

Dovetailing, in algorithm design, is a technique that interweaves different computations, performing them essentially simultaneously.

Consider a tree that potentially contains a path of infinite length (but each node has only finitely many children): if a depth-first search is performed in this environment, the search may move down an infinite path and never return, potentially leaving part of the tree unexplored.

In the case where one of the programs runs for an infinite amount of time, this transition will never happen.

The breadth-first approach of visiting each child on the same level of the tree is an instance of dovetailing, where a single step is performed for every program before moving to the next.

An analogy with the interweaving ends of a dovetail joint in woodworking.