Method of Four Russians
From Wikipedia, the free encyclopedia
In computer science, the Method of Four Russians or "The Four-Russians speedup,"[1] is a technique for speeding up algorithms involving Boolean matrices, or more generally algorithms involving matrices in which each cell may take on only a bounded number of possible values.
Idea
The main idea of the method is to partition the matrix into small square blocks of size t × t for some parameter t, and to use a lookup table to perform the algorithm quickly within each block. The index into the lookup table encodes the values of the matrix cells on the upper left of the block boundary prior to some operation of the algorithm, and the result of the lookup table encodes the values of the boundary cells on the lower right of the block after the operation. Thus, the overall algorithm may be performed by operating on only (n/t)2 blocks instead of on n2 matrix cells, where n is the side length of the matrix. In order to keep the size of the lookup tables (and the time needed to initialize them) sufficiently small, t is typically chosen to be O(log n).
The creation of the lookup tables can be done in O(n × t2) time, and if t is set to log n, this results in O(n (log n)2) time complexity for creating the tables. That time is still dominated by the search time O(n2/(log n)2) time (assuming unit-cost RAM).[1]
Applications
Algorithms to which the Method of Four Russians may be applied include:
- computing the transitive closure of a graph,
- Boolean matrix multiplication,
- edit distance calculation,
- sequence alignment,
- index calculation for binary jumbled pattern matching.
In each of these cases it speeds up the algorithm by one or two logarithmic factors.
The Method of Four Russians matrix inversion algorithm published by Bard is implemented in M4RI library for fast arithmetic with dense matrices over F2. M4RI is used by SageMath and the PolyBoRi library.[2]
History
The algorithm was introduced by V. L. Arlazarov, E. A. Dinic, M. A. Kronrod, and I. A. Faradžev in 1970.[3] The origin of the name is unknown; Aho, Hopcroft & Ullman (1974) explain:
- The second method, often called the "Four Russians'" algorithm, after the cardinality and nationality of its inventors, is somewhat more "practical" than the algorithm in Theorem 6.9.[4]
All four authors worked in Moscow, Russia in the Soviet Union at the time,[5] however, only Arlazarov was Russian; the name has thus been said to reflect the West's, "general level of ignorance about ethnicities in the then Soviet Union."[1]
Notes
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.