|
Divide-and-conquer Complexity and recurrences |
|
| Introduction |
| A fundamental idea |
| Complexity and recurrences |
| 2-rational sequences |
| Asymptotic behavior |
| References |
In each example which we have just met (cf. A fundamental idea) a natural concept of size of the data occurs. The size of a list is its length; the size of a polynomial is its degree; the size of a finite set of points is the number of its points. In addition a concept of cost of an algorithm also appears naturally. For a sorting algorithm it will be the number of comparisons or assignments carried out; for an algorithm of multiplication of matrices or polynomials it will be the number of scalar multiplications carried out. This cost depends on the data but it is normal to see it as a simple function of the size of the data; this reduction brings us to distinguish the cost in the worst case, the average cost and sometimes the cost in the best case.
Divide-and-conquer recurrences.
Let us consider again mergesort; the data is a list of size n
and the cost is the number of comparisons. According to
the divide-and-conquer strategy the cost for a data of size n
is the sum of the cost for a data of size
,
and of the cost for a data of size
,
plus the cost of the merge. In the worst case the merge requires
n-1 comparisons, as one sees by considering the two sorted lists
and
with
.
The cost Tn of mergesort for a data of size
n in the worst case thus satisfies the recurrence
![]()
![]()
Recurrences of the preceding type with respect to n and n/2 can be named divide-and-conquer recurrences. However, before going further, it should be noticed that divide-and-conquer algorithms do not necessarily lead to divide-and-conquer recurrences. For example the average cost Cn of quicksort for a list of size n satisfies [25, p. 120], [33, p. 129]
![]()
Generating series. To formalize divide-and-conquer sequences it is more pleasant to consider the ordinary generating series
![]()
fx=fn if x is a natural integer n, fx=0 otherwise.
Two operations on sequences are the shift and the homothety
.
They are translated into the linear operations on the associated formal power series
![]()
A formal series f(z) is called Mahlerian if it satisfies an equation
![]()
![]()
In this formula the sums comprise only a finite number of terms
and the coefficients
are not all zero. Mahlerian series are thus named after Kurt Mahler,
who studied the number bn of binary
partitions from the asymptotic point of
view [29].
A partition of the integer n is binary if
all its summands are powers of 2; for example
27=1+1+1+2+2+4+8+8
is a binary partition of 27. The sequence (bn) satisfies the recurrence![]()
![]()
![]()
![]()
One could generalize the definition by considering equations relating f(z) and f(zB), where B is an integer at least equal to 2 but the qualitative results are of the same type as for B= 2 and the case B= 2 is by far the most common in the applications.
Thus a class of series is defined, which satisfies the following closure properties:
![]()
A series f(z) is of the divide-and-conquer type if it satisfies an equation with a right member
![]()
Applicability.
Divide-and-conquer series appear in various fields. The example of
binary partitions shows that they occur in combinatorics. In the same
orbit one notices examples from combinatorics on words: the
correlation of two words u and v is a word on the
alphabet
obtained while gliding the second word along the first, and by noting
coincidence in the common part; in particular the autocorrelation of
a word indicates its repetitions. This concept occurs in the study of
the number of occurrences of a pattern in a text or, on the contrary,
in the study of words with prohibited
patterns [23].
One shows that the generating series for the enumeration of words with
a given autocorrelation is
Mahlerian [22].
These series also occur in the problems involved in the binary expansion of the integers. A traditional example is the sequence (sn) which gives the number of 1s in the binary expansion of the integers between 1 and n [11].
Of course the divide-and-conquer strategy provides a lot of examples. For example the multiplication of two polynomials of degree n uses three multiplications of polynomials with degrees half of n and roughly 3n additions of coefficients. Besause the cost is an increasing function of n, a sequence which gives an upper bound for the cost of the multiplication of two polynomials of degree n is the sequence (Pn) defined by [26, p. 278]
![]()
![]()
| Previous page: | A fundamental idea |
| Next page: | 2-rational sequences |