**3. Quasi-metric spaces and Asymptotic Complexity Analysis: the Schellekens approach**

In 1995, Schellekens introduced a new mathematical framework, now known as the Complexity Space, with the aim to contribute to the topological foundation for the Asymptotic Complexity Analysis of Algorithms via the application of the original Scott ideas for Denotational Semantics, that is via the application of fixed point and successive approximations reasoning, (Schellekens, 1995). This framework is based on the notion of a quasi-metric space.

Following (Künzi, 1993), a quasi-metric on a nonempty set *<sup>X</sup>* is a function *<sup>d</sup>* : *<sup>X</sup>* <sup>×</sup> *<sup>X</sup>* <sup>→</sup> **<sup>R</sup>**<sup>+</sup> such that for all *x*, *y*, *z* ∈ *X* :

(*i*) *d*(*x*, *y*) = *d*(*y*, *x*) = 0 ⇔ *x* = *y*; (*ii*) *d*(*x*, *y*) ≤ *d*(*x*, *z*) + *d*(*z*, *y*).

Of course a metric on a nonempty set *X* is a quasi-metric *d* on *X* satisfying, in addition, the following condition for all *x*, *y* ∈ *X*:

$$(\text{iii})\ d(\mathbf{x}, \mathbf{y}) = d(\mathbf{y}, \mathbf{x}).$$

4 Will-be-set-by-IN-TECH

A typical resource, playing a central role in complexity analysis, is the running time of computing. Since there are often many algorithms to solve the same problem, one objective of the complexity analysis is to assess which of them is faster when large inputs are considered. To this end, it is required to compare their running time of computing. This is usually done by means of the asymptotic analysis in which the running time of an algorithm is denoted by a function *T* : **N** → (0, ∞] in such a way that *T*(*n*) represents the time taken by the algorithm to solve the problem under consideration when the input of the algorithm is of size *n*. Of course the running time of an algorithm does not only depend on the input size *n*, but it depends also on the particular input of the size *n* (and the distribution of the data). Thus the running time of an algorithm is different when the algorithm processes certain instances of input data of the same size *n*. As a consequence, it is usually necessary to distinguish three possible behaviors when the running time of an algorithm is discussed. These are the so-called best case, the worst case and the average case. The best case and the worst case for an input of size *n* are defined by the minimum and the maximum running time of computing over all inputs of size *n*, respectively. The average case for an input of size *n* is defined by the expected value or

In general, given an algorithm, to determine exactly the function which describes its running time of computing is an arduous task. However, in most situations is more useful to know the running time of computing of an algorithm in an "approximate" way than in an exact one. For this reason the Asymptotic Complexity Analysis focus its interest on obtaining the

In order to recall the notions from Asymptotic Complexity Analysis which will be useful for our aim later on, let us assume that *f* : **N** → (0, ∞] denotes the running time of computing of a certain algorithm under study. Moreover, consider that there exists a function *g* : **N** → (0, ∞] such that there exist, simultaneously, *<sup>n</sup>*<sup>0</sup> <sup>∈</sup> **<sup>N</sup>** and *<sup>c</sup>* <sup>∈</sup> **<sup>R</sup>**<sup>+</sup> satisfying *<sup>f</sup>*(*n*) <sup>≤</sup> *cg*(*n*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>** with *<sup>n</sup>* <sup>≥</sup> *<sup>n</sup>*<sup>0</sup> (<sup>≤</sup> and <sup>≥</sup> stand for the usual orders on **<sup>R</sup>**+). Then, the function *<sup>g</sup>* provides an asymptotic upper bound of the running time of the studied algorithm. Hence, if we do not know the exact expression of the function *f* , then the function *g* gives an "approximate" information of the running time of the algorithm for each input size *n*, *f*(*n*), in the sense that the algorithm takes a time to process the input data of size *n* bounded above by the value *g*(*n*). Following the standard notation, when *g* is an upper asymptotic bound of *f* we will

In the analysis of the complexity of an algorithm, besides obtaining an upper asymptotic bound, it is useful to assess an asymptotic lower bound of the running time of computing. In this case the Ω-notation plays a central role. Indeed, the statement *f* ∈ Ω(*g*) means that there exist *<sup>n</sup>*<sup>0</sup> <sup>∈</sup> **<sup>N</sup>** and *<sup>c</sup>* <sup>∈</sup> **<sup>R</sup>**<sup>+</sup> such that *cg*(*n*) <sup>≤</sup> *<sup>f</sup>*(*n*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>** with *<sup>n</sup>* <sup>≥</sup> *<sup>n</sup>*0. Of course, and similarly to the O-notation case, when the time taken by the algorithm to process an input data of size *n*, *f*(*n*), is unknown, the function *g* yields an "approximate" information of the running time of the algorithm in the sense that the algorithm takes a time to process the input

Of course, when the complexity of an algorithm is discussed, the best situation matches up with the case in which we can find a function *g* : **N** → (0, ∞] in such a way that the running time *f* holds the condition *f* ∈ O(*g*) ∩ Ω(*g*), denoted by *f* ∈ Θ(*g*), since, in this case, we obtain a "tight "asymptotic bound of *f* and, thus, a total asymptotic information about the

average running time of computing over all inputs of size *n*.

"approximate" running time of computing.

data of size *n* bounded below by *g*(*n*).

write *f* ∈ O(*g*).

A quasi-metric space is a pair (*X*, *d*) such that *X* is a nonempty set and *d* is a quasi-metric on *X*.

Each quasi-metric *d* on *X* generates a *T*0-topology T (*d*) on *X* which has as a base the family of open *d*-balls {*Bd*(*x*,*ε*) : *x* ∈ *X*, *ε* > 0}, where *Bd*(*x*,*ε*) = {*y* ∈ *X* : *d*(*x*, *y*) < *ε*} for all *x* ∈ *X* and *ε* > 0.

Given a quasi-metric *<sup>d</sup>* on *<sup>X</sup>*, the function *<sup>d</sup><sup>s</sup>* defined on *<sup>X</sup>* <sup>×</sup> *<sup>X</sup>* by

$$d^s(\mathfrak{x}, \mathfrak{y}) = \max\left(d(\mathfrak{x}, \mathfrak{y}), d(\mathfrak{y}, \mathfrak{x})\right),$$

is a metric on *X*.

A quasi-metric space (*X*, *d*) is called bicomplete whenever the metric space (*X*, *ds*) is complete.

A well-known example of a bicomplete quasi-metric space is the pair ((0, <sup>∞</sup>], *<sup>u</sup>*−1), where

$$u\_{-1}(x,y) = \max\left(\frac{1}{y} - \frac{1}{x}, 0\right),$$

for all *<sup>x</sup>*, *<sup>y</sup>* <sup>∈</sup> (0, <sup>∞</sup>]. Obviously we adopt the convention that <sup>1</sup> <sup>∞</sup> = 0. The quasi-metric space ((0, <sup>∞</sup>], *<sup>u</sup>*−1) plays a central role in the Schellekens framework. Indeed, let us recall that the

algorithm combines all subproblem solutions to give a global solution to the original problem. The recursive structure of a Divide and Conquer algorithm leads to a recurrence equation for the running time of computing. In many cases the running time of a Divide and Conquer algorithm is the solution to a Divide and Conquer recurrence equation, that is a recurrence

<sup>105</sup> A Common Mathematical Framework for Asymptotic Complexity Analysis

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

*<sup>T</sup>*(*n*) = � *<sup>c</sup>* if *<sup>n</sup>* <sup>=</sup> <sup>1</sup> *aT*( *<sup>n</sup>*

all subproblems solutions into a unique one (*h* ∈ C with *h*(*n*) < ∞ for all *n* ∈ **N**).

et al., 1985) for a detailed discussion about the both aforasaid algorithms).

of (Romaguera & Schellekens, 1999)) and the set <sup>C</sup>*b*,*<sup>c</sup>* is closed in (C, *<sup>d</sup><sup>s</sup>*

*a f*( *<sup>n</sup>*

*<sup>d</sup>*<sup>C</sup> |C*b*,*<sup>c</sup>* (Φ*T*(*f*), <sup>Φ</sup>*T*(*g*)) ≤

⎧ ⎨ ⎩

where **<sup>N</sup>***<sup>b</sup>* <sup>=</sup> {*b<sup>k</sup>* : *<sup>k</sup>* <sup>∈</sup> **<sup>N</sup>**}, *<sup>c</sup>* <sup>&</sup>gt; 0 denotes the complexity on the base case (i.e. the problem size is small enough and the solution takes constant time), and *h*(*n*) represents the time taken by the algorithm in order to divide the original problem into *a* subproblems and to combine

Notice that for Divide and Conquer algorithms, it is typically sufficient to obtain the complexity on inputs of size *n* with *n* ranges over the set **N***<sup>b</sup>* (see (Brassard & Bratley, 1988)

Mergesort (in all behaviors) and Quicksort (in the best case behavior) are typical and well-known examples of Divide and Conquer algorithms whose running time of computing satisfies the recurrence equation (2) (we refer the reader to (Brassard & Bratley, 1988) and (Cull

In order to provide the asymptotic behavior of the running time of computing of a Divide and Conquer algorithm satisfying the recurrence equation (2), it is necessary to show that such a recurrence equation has a unique solution and, later, to obtain the asymptotic complexity class of such a solution. The method introduced by Schellekens allows us to show that the equation (2) has a unique solution, and provides an upper asymptotic complexity bound of

C*b*,*<sup>c</sup>* = { *f* ∈ C : *f*(1) = *c* and *f*(*n*) = ∞ for all *n* ∈ **N**\**N***<sup>b</sup>* with *n* > 1}.

Since the quasi-metric space (C, *<sup>d</sup>*<sup>C</sup> ) is bicomplete (see Theorem 3 and Remark in page 317

Next we associate a functional Φ*<sup>T</sup>* : C*b*,*<sup>c</sup>* −→ C*b*,*<sup>c</sup>* with the Divide and Conquer recurrence

*c* if *n* = 1

*<sup>b</sup>* ) + *h*(*n*) otherwise

Of course a complexity function in C*b*,*<sup>c</sup>* is a solution to the recurrence equation (2) if and only if it is a fixed point of the functional Φ*T*. Under these conditions, Schellekens proved

∞ if *n* ∈ **N**\**N***<sup>b</sup>* and *n* > 1

1 *a*

*<sup>b</sup>* ) + *h*(*n*) if *n* ∈ **N***<sup>b</sup>*

, (2)

<sup>C</sup> ), we have that the

. (3)

*<sup>d</sup>*<sup>C</sup> |C*b*,*<sup>c</sup>* (*<sup>f</sup>* , *<sup>g</sup>*), (4)

equation of the form

for a fuller description).

the solution in the following way:

equation (2) as follows:

(Schellekens, 1995) that

Denote by C*b*,*<sup>c</sup>* the subset of C given by

quasi-metric space (C*b*,*c*, *<sup>d</sup>*<sup>C</sup> |C*b*,*<sup>c</sup>* ) is bicomplete.

Φ*T*(*f*)(*n*) =

complexity space is the pair (C, *<sup>d</sup>*<sup>C</sup> ), where

$$\mathcal{C} = \{ f: \mathbb{N} \to (0, \infty] \, : \, \sum\_{n=1}^{\infty} 2^{-n} \frac{1}{f(n)} < \infty \},$$

and *<sup>d</sup>*<sup>C</sup> is the quasi-metric (so-called complexity distance) on C defined by

$$d\_{\mathcal{C}}(f, \mathcal{g}) = \sum\_{n=1}^{\infty} 2^{-n} u\_{-1}(f(n), \mathcal{g}(n)) = \sum\_{n=1}^{\infty} 2^{-n} \max\left(\frac{1}{\mathcal{g}(n)} - \frac{1}{f(n)}, 0\right).$$

According to (Schellekens, 1995), since every reasonable algorithm, from a computability viewpoint, must hold the "convergence condition" ∑<sup>∞</sup> *<sup>n</sup>*=<sup>1</sup> <sup>2</sup>−*<sup>n</sup>* <sup>1</sup> *<sup>f</sup>*(*n*) < ∞, it is possible to associate each algorithm with a function of C in such a way that such a function represents, as a function of the size of the input data, its running time of computing. Motivated by this fact, the elements of C are called complexity functions. Moreover, given two functions *<sup>f</sup>* , *<sup>g</sup>* ∈ C, the numerical value *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) (the complexity distance from *<sup>f</sup>* to *<sup>g</sup>*) can be interpreted as the relative progress made in lowering the complexity by replacing any algorithm *P* with complexity function *f* by any algorithm *Q* with complexity function *g*. Therefore, if *f* �= *g*, the condition *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = 0 can be read as *<sup>f</sup>* is "at least as efficient" as *<sup>g</sup>* on all inputs (note that *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = <sup>0</sup> ⇔ *<sup>f</sup>*(*n*) ≤ *<sup>g</sup>*(*n*) for all *<sup>n</sup>* ∈ **<sup>N</sup>**). In fact, the condition *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = 0 provides that *f* ∈ O(*g*).

Notice that the asymmetry of the complexity distance *<sup>d</sup>*<sup>C</sup> plays a central role in order to provide information about the increase of complexity whenever an algorithm is replaced by another one. A metric will be able to yield information on the increase but it, however, will not reveal which algorithm is more efficient.

The utility of the complexity space in complexity analysis of algorithms was also illustrated by Schellekens in (Schellekens, 1995). In particular, he introduced a mathematical method to provide asymptotic upper bounds of the running time of computing for Divide and Conquer algorithms. To this end, Schellekens used the below fixed point theorem which is a quasi-metric version of the celebrate Banach's fixed point theorem.

**Theorem 1.** *Let f be a contractive mapping from a bicomplete quasi-metric space* (*X*, *d*) *into itself with contractive constant s. Then f has a unique fixed point x*<sup>0</sup> *and, in addition,* lim*n*→<sup>∞</sup> *<sup>f</sup> <sup>n</sup>*(*x*) = *<sup>x</sup>*<sup>0</sup> *for all x* ∈ *X.*

Let us remark that a mapping *f* from a quasi-metric space (*X*, *d*) into itself it is called contractive provided that there exists *s* ∈ [0, 1) such that for all *x*, *y* ∈ *X*

$$d(f(x), f(y)) \le s d(x, y).$$

In this case, *s* is called a contractive constant of *f* .

Next we recall the aforenamed method with the aim of motivating our subsequent work, given in Sections 4 and 5.

A Divide and Conquer algorithm solves a problem of size *n* (*n* ∈ **N**) splitting it into *a* subproblems of size *<sup>n</sup> <sup>b</sup>* , for some constants *a*, *b* with *a*, *b* ∈ **N** and *a*, *b* > 1, and solving them separately by the same algorithm. After obtaining the solution of the subproblems, the algorithm combines all subproblem solutions to give a global solution to the original problem. The recursive structure of a Divide and Conquer algorithm leads to a recurrence equation for the running time of computing. In many cases the running time of a Divide and Conquer algorithm is the solution to a Divide and Conquer recurrence equation, that is a recurrence equation of the form

$$T(n) = \begin{cases} c & \text{if } n = 1\\ aT(\frac{n}{b}) + h(n) \text{ if } n \in \mathbb{N}\_b \text{ }' \end{cases} \tag{2}$$

where **<sup>N</sup>***<sup>b</sup>* <sup>=</sup> {*b<sup>k</sup>* : *<sup>k</sup>* <sup>∈</sup> **<sup>N</sup>**}, *<sup>c</sup>* <sup>&</sup>gt; 0 denotes the complexity on the base case (i.e. the problem size is small enough and the solution takes constant time), and *h*(*n*) represents the time taken by the algorithm in order to divide the original problem into *a* subproblems and to combine all subproblems solutions into a unique one (*h* ∈ C with *h*(*n*) < ∞ for all *n* ∈ **N**).

Notice that for Divide and Conquer algorithms, it is typically sufficient to obtain the complexity on inputs of size *n* with *n* ranges over the set **N***<sup>b</sup>* (see (Brassard & Bratley, 1988) for a fuller description).

Mergesort (in all behaviors) and Quicksort (in the best case behavior) are typical and well-known examples of Divide and Conquer algorithms whose running time of computing satisfies the recurrence equation (2) (we refer the reader to (Brassard & Bratley, 1988) and (Cull et al., 1985) for a detailed discussion about the both aforasaid algorithms).

In order to provide the asymptotic behavior of the running time of computing of a Divide and Conquer algorithm satisfying the recurrence equation (2), it is necessary to show that such a recurrence equation has a unique solution and, later, to obtain the asymptotic complexity class of such a solution. The method introduced by Schellekens allows us to show that the equation (2) has a unique solution, and provides an upper asymptotic complexity bound of the solution in the following way:

Denote by C*b*,*<sup>c</sup>* the subset of C given by

6 Will-be-set-by-IN-TECH

∞ ∑ *n*=1

> ∞ ∑ *n*=1

According to (Schellekens, 1995), since every reasonable algorithm, from a computability

associate each algorithm with a function of C in such a way that such a function represents, as a function of the size of the input data, its running time of computing. Motivated by this fact, the elements of C are called complexity functions. Moreover, given two functions *<sup>f</sup>* , *<sup>g</sup>* ∈ C, the numerical value *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) (the complexity distance from *<sup>f</sup>* to *<sup>g</sup>*) can be interpreted as the relative progress made in lowering the complexity by replacing any algorithm *P* with complexity function *f* by any algorithm *Q* with complexity function *g*. Therefore, if *f* �= *g*, the condition *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = 0 can be read as *<sup>f</sup>* is "at least as efficient" as *<sup>g</sup>* on all inputs (note that *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = <sup>0</sup> ⇔ *<sup>f</sup>*(*n*) ≤ *<sup>g</sup>*(*n*) for all *<sup>n</sup>* ∈ **<sup>N</sup>**). In fact, the condition *<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) = 0 provides that

Notice that the asymmetry of the complexity distance *<sup>d</sup>*<sup>C</sup> plays a central role in order to provide information about the increase of complexity whenever an algorithm is replaced by another one. A metric will be able to yield information on the increase but it, however, will

The utility of the complexity space in complexity analysis of algorithms was also illustrated by Schellekens in (Schellekens, 1995). In particular, he introduced a mathematical method to provide asymptotic upper bounds of the running time of computing for Divide and Conquer algorithms. To this end, Schellekens used the below fixed point theorem which is

**Theorem 1.** *Let f be a contractive mapping from a bicomplete quasi-metric space* (*X*, *d*) *into itself with contractive constant s. Then f has a unique fixed point x*<sup>0</sup> *and, in addition,* lim*n*→<sup>∞</sup> *<sup>f</sup> <sup>n</sup>*(*x*) = *<sup>x</sup>*<sup>0</sup>

Let us remark that a mapping *f* from a quasi-metric space (*X*, *d*) into itself it is called

*d*(*f*(*x*), *f*(*y*)) ≤ *sd*(*x*, *y*).

Next we recall the aforenamed method with the aim of motivating our subsequent work,

A Divide and Conquer algorithm solves a problem of size *n* (*n* ∈ **N**) splitting it into *a*

them separately by the same algorithm. After obtaining the solution of the subproblems, the

*<sup>b</sup>* , for some constants *a*, *b* with *a*, *b* ∈ **N** and *a*, *b* > 1, and solving

a quasi-metric version of the celebrate Banach's fixed point theorem.

contractive provided that there exists *s* ∈ [0, 1) such that for all *x*, *y* ∈ *X*

<sup>2</sup>−*<sup>n</sup>* <sup>1</sup>

2−*<sup>n</sup>* max

*<sup>f</sup>*(*n*) <sup>&</sup>lt; <sup>∞</sup>},

*<sup>n</sup>*=<sup>1</sup> <sup>2</sup>−*<sup>n</sup>* <sup>1</sup>

1

*<sup>g</sup>*(*n*) <sup>−</sup> <sup>1</sup>

*f*(*n*) , 0 .

*<sup>f</sup>*(*n*) < ∞, it is possible to

C = { *f* : **N** → (0, ∞] :

and *<sup>d</sup>*<sup>C</sup> is the quasi-metric (so-called complexity distance) on C defined by

<sup>2</sup><sup>−</sup>*nu*−1(*f*(*n*), *<sup>g</sup>*(*n*)) =

complexity space is the pair (C, *<sup>d</sup>*<sup>C</sup> ), where

∞ ∑ *n*=1

not reveal which algorithm is more efficient.

In this case, *s* is called a contractive constant of *f* .

viewpoint, must hold the "convergence condition" ∑<sup>∞</sup>

*<sup>d</sup>*<sup>C</sup> (*<sup>f</sup>* , *<sup>g</sup>*) =

*f* ∈ O(*g*).

*for all x* ∈ *X.*

given in Sections 4 and 5.

subproblems of size *<sup>n</sup>*

$$\mathcal{C}\_{b,c} = \{ f \in \mathcal{C} : f(1) = c \text{ and } f(n) = \infty \text{ for all } n \in \mathbb{N} \, |\, \mathbb{N}\_b \text{ with } n > 1 \}.$$

Since the quasi-metric space (C, *<sup>d</sup>*<sup>C</sup> ) is bicomplete (see Theorem 3 and Remark in page 317 of (Romaguera & Schellekens, 1999)) and the set <sup>C</sup>*b*,*<sup>c</sup>* is closed in (C, *<sup>d</sup><sup>s</sup>* <sup>C</sup> ), we have that the quasi-metric space (C*b*,*c*, *<sup>d</sup>*<sup>C</sup> |C*b*,*<sup>c</sup>* ) is bicomplete.

Next we associate a functional Φ*<sup>T</sup>* : C*b*,*<sup>c</sup>* −→ C*b*,*<sup>c</sup>* with the Divide and Conquer recurrence equation (2) as follows:

$$\Phi\_T(f)(n) = \begin{cases} c & \text{if } n = 1 \\ \infty & \text{if } n \in \mathbb{N} \backslash \mathbb{N}\_b \text{ and } n > 1 \\ af(\frac{n}{b}) + h(n) \text{ otherwise} \end{cases} \tag{3}$$

Of course a complexity function in C*b*,*<sup>c</sup>* is a solution to the recurrence equation (2) if and only if it is a fixed point of the functional Φ*T*. Under these conditions, Schellekens proved (Schellekens, 1995) that

$$d\_{\mathcal{C}}|\_{\mathcal{C}\_{b,\varepsilon}}(\Phi\_T(f), \Phi\_T(g)) \le \frac{1}{a} d\_{\mathcal{C}}|\_{\mathcal{C}\_{b,\varepsilon}}(f, g)\_{\prime} \tag{4}$$

case of recurrence equation (2):

equivalent to verify that Φ*T*(*f*) ≤ *f* .

that the running time of computing *f <sup>M</sup>*

asymptotic upper bound of *f <sup>M</sup>*

bound was obtained.

**algorithms**

preceding section.

by

Therefore, by Theorem 2, we can conclude that *f <sup>M</sup>*

to O(*n* log2 *n*), i.e. that the complexity function *g* <sup>1</sup>

*T* .

*<sup>T</sup>*(*n*) = *<sup>c</sup>* if *<sup>n</sup>* <sup>=</sup> <sup>1</sup> 2*T*( *<sup>n</sup>* <sup>2</sup> ) + *<sup>n</sup>*

It is clear that Theorem 2 shows that the recurrence equation (5) has a unique solution *f <sup>M</sup>*

<sup>107</sup> A Common Mathematical Framework for Asymptotic Complexity Analysis

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

in C2,*c*. In addition, it is not hard to check that the functional Φ*<sup>T</sup>* induced by the recurrence equation (5), and given by (3), is an improver with respect to a complexity function *gk* ∈ <sup>C</sup>2,*<sup>c</sup>* (with *<sup>k</sup>* <sup>&</sup>gt; 0, *gk*(1) = *<sup>c</sup>* and *gk*(*n*) = *kn* log2 *<sup>n</sup>* for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**2) if and only if *<sup>k</sup>* <sup>≥</sup> <sup>1</sup>

Note that under the assumption that the functional Φ in (3) is monotone, this is the case for the functional Φ*<sup>T</sup>* induced by (5), to show that Φ*<sup>T</sup>* is an improver with respect to *f* ∈ *C* is

new formal proof, inspired by the original Scott fixed point approach, of the well-known fact

Furthermore, it must be stressed that in (Schellekens, 1995) it was pointed out that an asymptotic lower bound of the running time of Mergesort (in the average case behavior) belongs to Ω(*n* log2 *n*). However, to show this standard arguments, which are not based on the use of fixed point techniques, were followed. So Schellekens proved that Mergesort running time (in the average case behavior) belongs to the complexity class Θ(*n* log2 *n*), but the unique, strictly speaking, novel proof of the last fact was given when the asymptotic upper

Although the most natural is to think that the running time of computing of Divide and Conquer algorithms is always the solution to a Divide and Conquer recurrence equations of type (2), there are well-known examples, like Quicksort (worst case behaviour), of Divide and Conquer algorithms whose complexity analysis does not lead with a recurrence equation of the aforesaid type (Cull et al., 1985). In particular, the running time of computing (worst case behavior) for the aforenamed algorithm is the solution to the recurrence equation given

*<sup>T</sup>*(*n*) = *<sup>c</sup>* if *<sup>n</sup>* <sup>=</sup> <sup>1</sup>

with *j* > 0 and where *c* is the time taken by the algorithm in the base case. Observe that in this case it is not necessary to restrict the input size of the data to a set **N***<sup>b</sup>* as defined in the

Clearly, the recurrence equation (6) can not be retrieved as a particular case of the Divide and Conquer family of recurrence equations (2). However, the main and strong relationship between Mergesort and Quicksort is given by the fact that both are recursive algorithms. Obviously, the class of recursive algorithms is wider than the Divide and Conquer one. An

**4. An extension of Schellekens' approach: the general case of recursive**

<sup>2</sup> if *n* ∈ **N**<sup>2</sup>

*<sup>T</sup>* ∈ O(*g* <sup>1</sup>

2

2

*<sup>T</sup>* of Mergesort (in the average case behavior) belongs

*<sup>T</sup>*(*<sup>n</sup>* <sup>−</sup> <sup>1</sup>) + *jn* if *<sup>n</sup>* <sup>≥</sup> <sup>2</sup> , (6)

. (5)

), i.e. Theorem 2 provides a

, or equivalently O(*n* log2 *n*), gives an

*T*

2 .

for all *f* , *g* ∈ C*b*,*c*. So, by Theorem 1, the functional Φ*<sup>T</sup>* : C*b*,*<sup>c</sup>* −→ C*b*,*<sup>c</sup>* has a unique fixed point and, thus, the recurrence equation (2) has a unique solution.

In order to obtain the asymptotic upper bound of the solution to the recurrence equation (2), Schellekens introduced a special class of functionals known as improvers.

Let *C* ⊆ C. A functional Φ : *C* −→ *C* is called an improver with respect to a function *f* ∈ *C* provided that <sup>Φ</sup>*n*(*f*) <sup>≤</sup> <sup>Φ</sup>*n*−1(*f*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**. Of course <sup>Φ</sup>0(*f*) = *<sup>f</sup>* .

Observe that an improver is a functional which corresponds to a transformation on algorithms in such a way that the iterative applications of the transformation yield, from a complexity point of view, an improved algorithm at each step of the iteration.

Taking into account the exposed facts, Schellekens stated the following result in (Schellekens, 1995).

**Theorem 2.** *A Divide and Conquer recurrence of the form (2) has a unique solution fT in* C*b*,*<sup>c</sup> suh that* lim*n*→<sup>∞</sup> <sup>Φ</sup>*<sup>n</sup> <sup>T</sup>*(*g*) = *fT for all g* ∈ C*b*,*c. Moreover, if the functional* Φ*<sup>T</sup> associated with (2) is an improver with respect to some function g* ∈ C*b*,*c, then the solution to the recurrence equation satisfies that fT* ∈ O(*g*)*.*

Of course the preceding theorem states a few relationships between the Schellekens framework and the Scott one (see Section 1). Concretely, the solution to a recurrence equation of type (2) is the fixed point *fT* ∈ C*b*,*<sup>c</sup>* of the nonrecursive functional Φ*T*, which can be seen as the topological limit of the sequence of the successive iterations (Φ*<sup>n</sup> <sup>T</sup>*(*g*))*n*∈**<sup>N</sup>** where <sup>Φ</sup>*<sup>T</sup>* is an improver with respect to *g* ∈ C*b*,*c*. Note that in this case the functional Φ*<sup>T</sup>* plays the role of the nonrecursive functional *φf act* introduced in Section 1 and that the role of meaning of the factorial recursive denotational specification, i.e. the factorial function, is now played by the running time of computing *fT*. Moreover, the facts that functional Φ*<sup>T</sup>* is an improver and lim*n*→<sup>∞</sup> <sup>Φ</sup>*<sup>n</sup> <sup>T</sup>*(*g*) = *fT* in (C*b*,*c*, *<sup>d</sup><sup>s</sup>*|C*b*,*<sup>c</sup>* ) yield that each iteration gives more information about the solution to the recurrence equation (the running time of computing) than the preceding ones and, in addition, one has that the information about the running time of computing of the algorithm under study is exactly that which can be obtained from the elements of such a sequence. Hence the role of the distinguished element *f*<sup>1</sup> and the successive approximations sequence (*φn*(*f*1))*n*∈**<sup>N</sup>** of the Scott framework, is now played by the sequence of improved running time versions of the Divide and Conquer algorithm under study, (Φ*<sup>n</sup> <sup>T</sup>*(*g*))*n*∈**N**, and the complexity function *g* ∈ C*b*,*<sup>c</sup>* with respect to which the nonrecursive functional Φ*<sup>T</sup>* is an improver. These analogies between the Schellekens and Scott techniques give relevance to the former one with respect to the standard and classical techniques to analyze the complexity of algorithms. Simultaneously, the framework based on the complexity space presents an advantage with respect to the Scott one. Indeed, the framework of Schellekens counts on a topology induced by a quasi-metric (the complexity distance) which allows to measure the information about the fixed point of the nonrecursive functional contained in each element of the sequence of successive approximations and the framework of Scott has not available, in general, quantitative data approach.

In order to validate Theorem 2 and to illustrate its usefulness, Schellekens obtained an upper asymptotic bound of the running time of Mergesort (in the average case behavior). In this particular case, the Mergesort running time of computing satisfies the following particular case of recurrence equation (2):

8 Will-be-set-by-IN-TECH

for all *f* , *g* ∈ C*b*,*c*. So, by Theorem 1, the functional Φ*<sup>T</sup>* : C*b*,*<sup>c</sup>* −→ C*b*,*<sup>c</sup>* has a unique fixed point

In order to obtain the asymptotic upper bound of the solution to the recurrence equation (2),

Let *C* ⊆ C. A functional Φ : *C* −→ *C* is called an improver with respect to a function *f* ∈ *C*

Observe that an improver is a functional which corresponds to a transformation on algorithms in such a way that the iterative applications of the transformation yield, from a complexity

Taking into account the exposed facts, Schellekens stated the following result in (Schellekens,

**Theorem 2.** *A Divide and Conquer recurrence of the form (2) has a unique solution fT in* C*b*,*<sup>c</sup> suh*

*improver with respect to some function g* ∈ C*b*,*c, then the solution to the recurrence equation satisfies*

Of course the preceding theorem states a few relationships between the Schellekens framework and the Scott one (see Section 1). Concretely, the solution to a recurrence equation of type (2) is the fixed point *fT* ∈ C*b*,*<sup>c</sup>* of the nonrecursive functional Φ*T*, which can be seen

an improver with respect to *g* ∈ C*b*,*c*. Note that in this case the functional Φ*<sup>T</sup>* plays the role of the nonrecursive functional *φf act* introduced in Section 1 and that the role of meaning of the factorial recursive denotational specification, i.e. the factorial function, is now played by the running time of computing *fT*. Moreover, the facts that functional Φ*<sup>T</sup>* is an improver and

the solution to the recurrence equation (the running time of computing) than the preceding ones and, in addition, one has that the information about the running time of computing of the algorithm under study is exactly that which can be obtained from the elements of such a sequence. Hence the role of the distinguished element *f*<sup>1</sup> and the successive approximations sequence (*φn*(*f*1))*n*∈**<sup>N</sup>** of the Scott framework, is now played by the sequence of improved

the complexity function *g* ∈ C*b*,*<sup>c</sup>* with respect to which the nonrecursive functional Φ*<sup>T</sup>* is an improver. These analogies between the Schellekens and Scott techniques give relevance to the former one with respect to the standard and classical techniques to analyze the complexity of algorithms. Simultaneously, the framework based on the complexity space presents an advantage with respect to the Scott one. Indeed, the framework of Schellekens counts on a topology induced by a quasi-metric (the complexity distance) which allows to measure the information about the fixed point of the nonrecursive functional contained in each element of the sequence of successive approximations and the framework of Scott has not available, in

In order to validate Theorem 2 and to illustrate its usefulness, Schellekens obtained an upper asymptotic bound of the running time of Mergesort (in the average case behavior). In this particular case, the Mergesort running time of computing satisfies the following particular

running time versions of the Divide and Conquer algorithm under study, (Φ*<sup>n</sup>*

*<sup>T</sup>*(*g*) = *fT* in (C*b*,*c*, *<sup>d</sup><sup>s</sup>*|C*b*,*<sup>c</sup>* ) yield that each iteration gives more information about

*<sup>T</sup>*(*g*) = *fT for all g* ∈ C*b*,*c. Moreover, if the functional* Φ*<sup>T</sup> associated with (2) is an*

*<sup>T</sup>*(*g*))*n*∈**<sup>N</sup>** where <sup>Φ</sup>*<sup>T</sup>* is

*<sup>T</sup>*(*g*))*n*∈**N**, and

and, thus, the recurrence equation (2) has a unique solution.

Schellekens introduced a special class of functionals known as improvers.

provided that <sup>Φ</sup>*n*(*f*) <sup>≤</sup> <sup>Φ</sup>*n*−1(*f*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**. Of course <sup>Φ</sup>0(*f*) = *<sup>f</sup>* .

point of view, an improved algorithm at each step of the iteration.

as the topological limit of the sequence of the successive iterations (Φ*<sup>n</sup>*

1995).

*that* lim*n*→<sup>∞</sup> <sup>Φ</sup>*<sup>n</sup>*

*that fT* ∈ O(*g*)*.*

lim*n*→<sup>∞</sup> <sup>Φ</sup>*<sup>n</sup>*

general, quantitative data approach.

$$T(n) = \begin{cases} c & \text{if } n = 1\\ 2T(\frac{n}{2}) + \frac{n}{2} \text{ if } n \in \mathbb{N}\_2 \text{ }. \end{cases} \tag{5}$$

It is clear that Theorem 2 shows that the recurrence equation (5) has a unique solution *f <sup>M</sup> T* in C2,*c*. In addition, it is not hard to check that the functional Φ*<sup>T</sup>* induced by the recurrence equation (5), and given by (3), is an improver with respect to a complexity function *gk* ∈ <sup>C</sup>2,*<sup>c</sup>* (with *<sup>k</sup>* <sup>&</sup>gt; 0, *gk*(1) = *<sup>c</sup>* and *gk*(*n*) = *kn* log2 *<sup>n</sup>* for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**2) if and only if *<sup>k</sup>* <sup>≥</sup> <sup>1</sup> 2 . Note that under the assumption that the functional Φ in (3) is monotone, this is the case for the functional Φ*<sup>T</sup>* induced by (5), to show that Φ*<sup>T</sup>* is an improver with respect to *f* ∈ *C* is equivalent to verify that Φ*T*(*f*) ≤ *f* .

Therefore, by Theorem 2, we can conclude that *f <sup>M</sup> <sup>T</sup>* ∈ O(*g* <sup>1</sup> 2 ), i.e. Theorem 2 provides a new formal proof, inspired by the original Scott fixed point approach, of the well-known fact that the running time of computing *f <sup>M</sup> <sup>T</sup>* of Mergesort (in the average case behavior) belongs to O(*n* log2 *n*), i.e. that the complexity function *g* <sup>1</sup> 2 , or equivalently O(*n* log2 *n*), gives an asymptotic upper bound of *f <sup>M</sup> T* .

Furthermore, it must be stressed that in (Schellekens, 1995) it was pointed out that an asymptotic lower bound of the running time of Mergesort (in the average case behavior) belongs to Ω(*n* log2 *n*). However, to show this standard arguments, which are not based on the use of fixed point techniques, were followed. So Schellekens proved that Mergesort running time (in the average case behavior) belongs to the complexity class Θ(*n* log2 *n*), but the unique, strictly speaking, novel proof of the last fact was given when the asymptotic upper bound was obtained.
