Dovetailing (computer Science)
   HOME

TheInfoList



OR:

Dovetailing, in
algorithm design In mathematics and computer science, an algorithm () is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for perf ...
, is a technique that interweaves different
computation A computation is any type of arithmetic or non-arithmetic calculation that is well-defined. Common examples of computation are mathematical equation solving and the execution of computer algorithms. Mechanical or electronic devices (or, hist ...
s, performing them essentially simultaneously. Algorithms that use dovetailing are sometimes referred to as dovetailers.


Examples

Consider a
tree In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, e.g., including only woody plants with secondary growth, only ...
that potentially contains a
path A path is a route for physical travel – see Trail. Path or PATH may also refer to: Physical paths of different types * Bicycle path * Bridle path, used by people on horseback * Course (navigation), the intended path of a vehicle * Desir ...
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 al ...
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 Breadth-first search (BFS) is an algorithm for searching a tree data structure for a node that satisfies a given property. It starts at the tree root and explores all nodes at the present depth prior to moving on to the nodes at the next dept ...
is used, the existence of an infinite path is no longer a problem: each
node In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex). Node may refer to: In mathematics * Vertex (graph theory), a vertex in a mathematical graph *Vertex (geometry), a point where two or more curves, lines ...
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 In theoretical computer science, a nondeterministic Turing machine (NTM) is a theoretical model of computation whose governing rules specify more than one possible action when in some given situations. That is, an NTM's next state is ''not'' comp ...
''M'' by a deterministic one (e.g. by a
universal Turing machine In computer science, a universal Turing machine (UTM) is a Turing machine capable of computing any computable sequence, as described by Alan Turing in his seminal paper "On Computable Numbers, with an Application to the Entscheidungsproblem". Co ...
). In such case, we need to use dovetailing in case one of the computation branches of ''M'' contains an infinite loop. Universal Dovetailing is mentioned in
Always Asking- Why Does Anything Exist
and also in the book "The Amoeba's Secret" by Bruno Marchal


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, a ...
in
woodworking Woodworking is the skill of making items from wood, and includes cabinetry, furniture making, wood carving, joinery, carpentry, and woodturning. History Along with stone, clay and animal parts, wood was one of the first materials worked b ...
.


See also

* Recursive enumeration


References

{{DEFAULTSORT:Dovetailing (Computer Science) Analysis of algorithms