HOME

TheInfoList



OR:

Dovetailing, in algorithm design, is a technique that interweaves different
computation Computation is any type of arithmetic or non-arithmetic calculation that follows a well-defined model (e.g., an algorithm). Mechanical or electronic devices (or, historically, people) that perform computations are known as ''computers''. An es ...
s, performing them essentially simultaneously. Algorithms that use dovetailing are sometimes referred to as dovetailers.


Examples

Consider a tree that potentially contains a path of infinite length (but each node has only finitely many children): if a
depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible alon ...
is performed in this environment, the search may move down an infinite path and never return, potentially leaving part of the tree unexplored. However, if a breadth-first search is used, the existence of an infinite path is no longer a problem: each node is visited in a branching manner according to its distance from the root, so an infinite path will only impact the part of the search travelling down that path. We can regard this tree as analogous to a collection of programs; in this case, the depth-first approach corresponds to running one program at a time, moving to the next only when the current program has finished running. 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. Thus, progress is made in each program, regardless of the potential existence of a non-terminating program. Another example is simulating a non-deterministic Turing machine ''M'' by a deterministic one (e.g. by a universal Turing machine). In such case, we need to use dovetailing in case one of the computation branches of ''M'' contains an infinite loop.


Infinitely many simultaneous computations

In the case of an infinite number of programs, all potentially infinitely long, neither the breadth-first nor depth-first would be sufficient to ensure progress on all programs. Instead, the following technique can be used: perform the first step of the first program; next, perform the second step of the first program and first step of the second program; next, perform the third step of the first program, second step of the second program and first step of the third program; and so on. This is thus also known as diagonalization (as used e.g. in Haskell's "universe" package or "Omega" monad).


Etymology

An analogy with the interweaving ends of a
dovetail joint A dovetail joint or simply dovetail is a joinery technique most commonly used in woodworking joinery (carpentry), including furniture, cabinets, log buildings, and traditional timber framing. Noted for its resistance to being pulled apart (ten ...
in woodworking.


See also

*
Recursive enumeration In computability theory, a set ''S'' of natural numbers is called computably enumerable (c.e.), recursively enumerable (r.e.), semidecidable, partially decidable, listable, provable or Turing-recognizable if: *There is an algorithm such that the ...
{{DEFAULTSORT:Dovetailing (Computer Science) Analysis of algorithms