The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.
The
SlowSort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of
ReluctantAlgorithms.
From "Pessimal algorithms and the simplexity of computations. A. Broder and J. Stolfi. (Satirical article.) ACM SIGACT News vol. 16 no. 7, 49--53. Fall 1984. [PS,6p,54kB] [bib]"
http://www.dcc.unicamp.br/~stolfi/EXPORT/papers/by-tag/bro-sto-84-pes.ps.gz
Another great example is calculation of the
FibonacciSequence. In the
PrologLanguage (if memory serves me):
fibo(0, 0).
fibo(1, 1).
fibo(N, F) :-
N > 1,
N1 is N - 1,
N2 is N - 2,
fibo(N1, F1),
fibo(N2, F2),
F is F1 + F2.
In Python:
def fibo(x):
if x < 2:
return 1
return fibo(x-1) + fibo(x-2)
Calculating fibo(n) this way takes fibo(n+1) steps!
And that would be another way of calculating fibo(n): counting the steps required to calculate fibo(n-1).
This is one of the symptoms/causes of my
AnalysisParalysis and other forms of
ChronicProcrastination.
I thought the title was going to lead to a joke about Catholicism :-)
See also
DivideAndConquer,
NextList
CategoryAlgorithm CategoryAntiPattern CategoryWhimsy