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

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 by

$$T(n) = \begin{cases} c & \text{if } n = 1\\ T(n-1) + jn \text{ if } n \ge 2 \end{cases} \tag{6}$$

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 preceding section.

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

On the other hand, the Schellekens fixed point technique was extended and applied to discuss the complexity class (asymptotic upper and lower bounds) of those algorithms whose running time of computing is the solution to a recurrence equation of type (8). Of course, it was introduced an improvement over the original Schellekens method in order to obtain asymptotic lower bounds of the running time of computing of algorithms. This was done by means of a new kind of functionals defined on the complexity space and called worseners (see Subsection 4.2 for the definition). Furthermore, the applicability of the new results to Asymptotic Complexity Analysis was illustrated by discussing the complexity class of the running time of computing, among others, of Quicksort (in the worst case behavior) and

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

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

Nevertheless, a recursive algorithm whose running time does not hold a recurrence equation of type (8) can be found, for instance, in (Cull et al., 1985). The aforementioned algorithm, that we will call Fibonacci, computes the value of the Fibonacci sequence at any given index *n* with *n* ∈ **N**. The running time of computing of Fibonacci matches up with the solution to a

where *c* represents the time taken by the computer to perform a basic operation. Again, similarly to Hanoi, to distinguish three possible running time behaviors is meaningless.

It is clear that the recurrence equation (11) can not be retrieved as a particular case from the family of recurrence equations (8). Consequently, the latter family of recurrence equations is not be able to model the complexity of Fibonacci. However, the running time of computing of all above recursive algorithms, including Fibonacci, can be modeled as the solution to a

*<sup>T</sup>*(*n*) = � *cn* if 1 <sup>≤</sup> *<sup>n</sup>* <sup>≤</sup> *<sup>k</sup>*

Inspired by the previous exposed fact our purpose in this section is to go more deeply into the Schellekens fixed point technique for the complexity analysis of algorithms and to demonstrate that such techniques can be successfully used to obtain the complexity class of those recursive algorithms whose running time is a solution to a recurrence equation of type (12). In particular we prove, by means of a new fixed point theorem, the existence and uniqueness of the solution to a recurrence equation of type (12). Moreover, we introduce, based on the fixed point theorem, a technique in the spirit of Schellekens and Scott to get the the complexity class (an asymptotic upper and lower bound) of such a solution. Concretely, our technique to obtain asymptotic upper bounds is based on, following the Schellekens original ideas, the use of improver functionals induced by the recurrence equation. Nevertheless, following (Romaguera et al., 2011), we provide asymptotic lower bounds of the solution via worseners functionals which capture, similarly to the improvers one but in a dual way, the original "successive approximations" spirit of Scott's approach.

where *h* ∈ C such that *h*(*n*) < ∞ for all *n* ∈ **N**, *k* ∈ **N**, *ci* > 0 and *ai* ≥ 1 for all 1 ≤ *i* ≤ *k*.

*<sup>i</sup>*=<sup>1</sup> *aiT*(*<sup>n</sup>* <sup>−</sup> *<sup>i</sup>*) + *<sup>h</sup>*(*n*) if *<sup>n</sup>* <sup>&</sup>gt; *<sup>k</sup>* , (12)

2*c* if *n* = 1 3*c* if *n* = 2 *T*(*n* − 1) + *T*(*n* − 2) + 4*c* if *n* > 2

, (11)

Hanoi.

recurrence equation given as follows:

*T*(*n*) =

recurrence equation of the below general family:

⎧ ⎨ ⎩

∑*k*

illustrative example, which does not belong to the Divide and Conquer family, is provided by the recursive algorithm, which we will call Hanoi, that solves the Towers of Hanoi puzzle (Cull et al., 1985; Cull & Ecklund, 1985). In this case, under the uniform cost criterion assumption, the running time of computing is the solution to a recurrence equation given by

$$T(n) = \begin{cases} c & \text{if } n = 1\\ 2T(n-1) + d \text{ if } n \ge 2 \end{cases} \tag{7}$$

where *c*, *d* > 0 and where *c* represents the time taken by the algorithm to solve the base case. Of course, to distinguish three possible running time behaviors for Hanoi is meaningless, since the input data distribution is always the same for each size *n*.

In (Romaguera et al., 2011), the fact that the class of recursive algorithms is wider than the Divide and Conquer inspired to wonder whether one can obtain a family of recurrence equations in such a way that the complexity analysis of those algorithms whose running time of computing is a solution either to recurrence equations associated with Quicksort (in the worst case behavior) and Hanoi or to a Divide and Conquer one can be carried out from it and, in addition, whether such a complexity analysis can be done via an extension of the fixed point technique of Schellekens.

A positive answer to the preceding questions was also given in (Romaguera et al., 2011). Concretely, it was shown two things.

On one hand, it was pointed out that the recurrence equations that yield the running time of computing of the above aforesaid algorithms can be considered as particular cases of the following general one:

$$T(n) = \begin{cases} c & \text{if } n = 1\\ aT(n-1) + h(n) \text{ if } n \ge 2 \end{cases} \tag{8}$$

where *c* > 0, *a* ≥ 1 and *h* ∈ C such that *h*(*n*) < ∞ for all *n* ∈ **N**.

Of course, the discussion of the complexity of the Divide and Conquer algorithms introduced in Section 3 can be carried out from the family of recurrence equations of type (8). This is possible because the running time of computing of the aforementioned algorithms leads to recurrence equations can be seen as a particular case of our last general family of recurrence equations. Indeed, a Divide and Conquer recurrence equation

$$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{9}$$

can be transformed into the following one

$$S(m) = \begin{cases} c & \text{if } m = 1\\ aS(m-1) + r(m) \text{ if } m > 1 \end{cases} \tag{10}$$

where *<sup>S</sup>*(*m*) = *<sup>T</sup>*(*bm*−1) and *<sup>r</sup>*(*m*) = *<sup>h</sup>*(*bm*−1) for all *<sup>m</sup>* <sup>∈</sup> **<sup>N</sup>**. (Recall that **<sup>N</sup>***<sup>b</sup>* <sup>=</sup> {*b<sup>k</sup>* : *<sup>k</sup>* <sup>∈</sup> **<sup>N</sup>**} with *b* ∈ **N** and *b* > 1).

Observe that the analysis of the recurrence equation family (10) allows immediately to study the Divide and Conquer recurrence equations.

10 Will-be-set-by-IN-TECH

illustrative example, which does not belong to the Divide and Conquer family, is provided by the recursive algorithm, which we will call Hanoi, that solves the Towers of Hanoi puzzle (Cull et al., 1985; Cull & Ecklund, 1985). In this case, under the uniform cost criterion assumption,

where *c*, *d* > 0 and where *c* represents the time taken by the algorithm to solve the base case. Of course, to distinguish three possible running time behaviors for Hanoi is meaningless, since

In (Romaguera et al., 2011), the fact that the class of recursive algorithms is wider than the Divide and Conquer inspired to wonder whether one can obtain a family of recurrence equations in such a way that the complexity analysis of those algorithms whose running time of computing is a solution either to recurrence equations associated with Quicksort (in the worst case behavior) and Hanoi or to a Divide and Conquer one can be carried out from it and, in addition, whether such a complexity analysis can be done via an extension of the fixed

A positive answer to the preceding questions was also given in (Romaguera et al., 2011).

On one hand, it was pointed out that the recurrence equations that yield the running time of computing of the above aforesaid algorithms can be considered as particular cases of the

Of course, the discussion of the complexity of the Divide and Conquer algorithms introduced in Section 3 can be carried out from the family of recurrence equations of type (8). This is possible because the running time of computing of the aforementioned algorithms leads to recurrence equations can be seen as a particular case of our last general family of recurrence

*c* if *n* = 1

*c* if *m* = 1

where *<sup>S</sup>*(*m*) = *<sup>T</sup>*(*bm*−1) and *<sup>r</sup>*(*m*) = *<sup>h</sup>*(*bm*−1) for all *<sup>m</sup>* <sup>∈</sup> **<sup>N</sup>**. (Recall that **<sup>N</sup>***<sup>b</sup>* <sup>=</sup> {*b<sup>k</sup>* : *<sup>k</sup>* <sup>∈</sup> **<sup>N</sup>**}

Observe that the analysis of the recurrence equation family (10) allows immediately to study

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

*aT*( *<sup>n</sup>*

*c* if *n* = 1

*c* if *n* = 1

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

*aT*(*<sup>n</sup>* <sup>−</sup> <sup>1</sup>) + *<sup>h</sup>*(*n*) if *<sup>n</sup>* <sup>≥</sup> <sup>2</sup> , (8)

*aS*(*<sup>m</sup>* <sup>−</sup> <sup>1</sup>) + *<sup>r</sup>*(*m*) if *<sup>m</sup>* <sup>&</sup>gt; <sup>1</sup> , (10)

, (9)

the running time of computing is the solution to a recurrence equation given by

*T*(*n*) =

the input data distribution is always the same for each size *n*.

*T*(*n*) =

where *c* > 0, *a* ≥ 1 and *h* ∈ C such that *h*(*n*) < ∞ for all *n* ∈ **N**.

equations. Indeed, a Divide and Conquer recurrence equation

*T*(*n*) =

*S*(*m*) =

point technique of Schellekens.

following general one:

with *b* ∈ **N** and *b* > 1).

Concretely, it was shown two things.

can be transformed into the following one

the Divide and Conquer recurrence equations.

On the other hand, the Schellekens fixed point technique was extended and applied to discuss the complexity class (asymptotic upper and lower bounds) of those algorithms whose running time of computing is the solution to a recurrence equation of type (8). Of course, it was introduced an improvement over the original Schellekens method in order to obtain asymptotic lower bounds of the running time of computing of algorithms. This was done by means of a new kind of functionals defined on the complexity space and called worseners (see Subsection 4.2 for the definition). Furthermore, the applicability of the new results to Asymptotic Complexity Analysis was illustrated by discussing the complexity class of the running time of computing, among others, of Quicksort (in the worst case behavior) and Hanoi.

Nevertheless, a recursive algorithm whose running time does not hold a recurrence equation of type (8) can be found, for instance, in (Cull et al., 1985). The aforementioned algorithm, that we will call Fibonacci, computes the value of the Fibonacci sequence at any given index *n* with *n* ∈ **N**. The running time of computing of Fibonacci matches up with the solution to a recurrence equation given as follows:

$$T(n) = \begin{cases} 2c & \text{if } n = 1 \\ 3c & \text{if } n = 2 \\ T(n-1) + T(n-2) + 4c \text{ if } n > 2 \end{cases} \tag{11}$$

where *c* represents the time taken by the computer to perform a basic operation. Again, similarly to Hanoi, to distinguish three possible running time behaviors is meaningless.

It is clear that the recurrence equation (11) can not be retrieved as a particular case from the family of recurrence equations (8). Consequently, the latter family of recurrence equations is not be able to model the complexity of Fibonacci. However, the running time of computing of all above recursive algorithms, including Fibonacci, can be modeled as the solution to a recurrence equation of the below general family:

$$T(n) = \begin{cases} c\_n & \text{if } 1 \le n \le k \\ \sum\_{i=1}^k a\_i T(n-i) + h(n) \text{ if } n > k \end{cases},\tag{12}$$

where *h* ∈ C such that *h*(*n*) < ∞ for all *n* ∈ **N**, *k* ∈ **N**, *ci* > 0 and *ai* ≥ 1 for all 1 ≤ *i* ≤ *k*.

Inspired by the previous exposed fact our purpose in this section is to go more deeply into the Schellekens fixed point technique for the complexity analysis of algorithms and to demonstrate that such techniques can be successfully used to obtain the complexity class of those recursive algorithms whose running time is a solution to a recurrence equation of type (12). In particular we prove, by means of a new fixed point theorem, the existence and uniqueness of the solution to a recurrence equation of type (12). Moreover, we introduce, based on the fixed point theorem, a technique in the spirit of Schellekens and Scott to get the the complexity class (an asymptotic upper and lower bound) of such a solution. Concretely, our technique to obtain asymptotic upper bounds is based on, following the Schellekens original ideas, the use of improver functionals induced by the recurrence equation. Nevertheless, following (Romaguera et al., 2011), we provide asymptotic lower bounds of the solution via worseners functionals which capture, similarly to the improvers one but in a dual way, the original "successive approximations" spirit of Scott's approach.

whenever *i* ≥ *i*0. As a result we have that

**Proof.** Let *f* , *g* ∈ C*c*,*k*. Then we prove that

*<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (Ψ*T*(*f*), <sup>Ψ</sup>*T*(*g*)) =

Since the metric space (C, *<sup>d</sup><sup>s</sup>*

C*c*,*k ds*

(C, *<sup>d</sup><sup>s</sup>*

type (12).

where

Indeed, we have that

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

<sup>C</sup> <sup>=</sup> <sup>C</sup>*c*,*<sup>k</sup>* and, thus, that <sup>C</sup>*c*,*<sup>k</sup>* is closed in (C, *<sup>d</sup><sup>s</sup>*

<sup>C</sup> ) we immediately obtain the following consequence. **Corollary 4.** *The quasi-metric space* (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ) *is bicomplete.*

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

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

*cn*1 | ≤

( max 1≤*i*≤*k*

*s* = ( max 1≤*i*≤*k*

∞ ∑ *n*=1

∞ ∑ *n*=*k*+2

∞ ∑ *n*=*k*+2

≤ ( max 1≤*i*≤*k*

≤ ( max 1≤*i*≤*k*

= ( max 1≤*i*≤*k*

=

≤

∞ ∑ *n*=1

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

which is a contradiction. So *g*(*n*) = *cn* for all 1 ≤ *n* ≤ *k*. Therefore we have shown that

The next result provides the existence and uniqueness of solution to a recurrence equation of

**Theorem 5.** *The functional* <sup>Ψ</sup>*<sup>T</sup> is contractive from* (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ) *into itself with contractive constant*

*<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (Ψ*T*(*f*), <sup>Ψ</sup>*T*(*g*)) ≤ *sd*<sup>C</sup> |C*c*,*<sup>k</sup>* (*<sup>f</sup>* , *<sup>g</sup>*),

1 *ai* ) <sup>2</sup>*<sup>k</sup>* <sup>−</sup> <sup>1</sup> 2*k*

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

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

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

1 *ai* ) ∞ ∑ *n*=*k*+2

1 *ai* ) ∞ ∑ *n*=*k*+1

1 *ai* ) <sup>2</sup>*<sup>k</sup>* <sup>−</sup> <sup>1</sup> 2*k*

 .

> .

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

∑*k*

∑*k*

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

∑*k <sup>i</sup>*=<sup>1</sup> *<sup>a</sup>*<sup>2</sup>

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

Ψ*T*(*f*)(*n*)

*<sup>i</sup>*=<sup>1</sup> *ai* (*f*(*n* − *i*) − *g*(*n* − *i*))

*<sup>i</sup>*=<sup>1</sup> *ai* (*f*(*n* − *i*) − *g*(*n* − *i*))

∑ *i*=1

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

, 0

*<sup>r</sup>*(*n*) , 0

*f*(*n* − *i*)

*f*(*n*)

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

, 0

, 0

*<sup>i</sup>* (*g*(*<sup>n</sup>* <sup>−</sup> *<sup>i</sup>*)*f*(*<sup>n</sup>* <sup>−</sup> *<sup>i</sup>*)) , 0

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

max <sup>1</sup>

1 *ai* ) <sup>2</sup>*<sup>k</sup>* <sup>−</sup> <sup>1</sup> 2*k*

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

*fi*<sup>0</sup> (*n*)

<sup>C</sup> ) is complete and, by Proposition 3, the subset <sup>C</sup>*c*,*<sup>k</sup>* is closed in

 < *ε*,

<sup>C</sup> ).

Furthermore, we prove that in order to provide the complexity class of an algorithm whose running time satisfies a recurrence equation of type (12) is enough to search among all complexity functions for which the functional associated to the recurrence equation is an improver and a worsener simultaneously. Finally, with the aim, on one hand, to validate our new results and, on the other hand, to show the potential applicability of the developed theory to Asymptotic Complexity Analysis, we end the section discussing the complexity class of the running time of Fibonacci.

#### **4.1 The fixed point: existence and uniqueness of solution**

Fix *k* ∈ **N**. Consider the subset C*c*,*<sup>k</sup>* of C given by

$$\mathcal{C}\_{\mathfrak{c},k} = \{ f \in \mathcal{C} : f(n) = c\_n \text{ for all } 1 \le n \le k \}.$$

Define the functional Ψ*<sup>T</sup>* : C*c*,*<sup>k</sup>* −→ C*c*,*<sup>k</sup>* by

$$\Psi\_T(f)(n) = \begin{cases} c\_n & \text{if } 1 \le n \le k \\ \sum\_{i=1}^k a\_i f(n-i) + h(n) \text{ if } n > k \end{cases},\tag{13}$$

for all *f* ∈ C*c*,*k*.

It is clear that a complexity function in C*c*,*<sup>k</sup>* is a solution to a recurrence equation of type (12) if and only if it is a fixed point of the functional Ψ*T*.

The next result is useful to supply the bicompleteness of the quasi-metric space (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ).

**Proposition 3.** *The subset* <sup>C</sup>*c*,*<sup>k</sup> is closed in* (C, *<sup>d</sup><sup>s</sup>* C ).

**Proof.** Let *g* ∈ C*c*,*<sup>k</sup> ds* <sup>C</sup> and (*fi*)*i*∈**<sup>N</sup>** ⊂ C*c*,*<sup>k</sup>* with lim*i*→<sup>∞</sup> *<sup>d</sup><sup>s</sup>* <sup>C</sup> (*g*, *fi*) = 0. First of all we prove that *<sup>g</sup>* ∈ C. Indeed, given *<sup>ε</sup>* <sup>&</sup>gt; 0, there exist *<sup>i</sup>*0, *<sup>n</sup>*<sup>0</sup> <sup>∈</sup> **<sup>N</sup>** such that *<sup>d</sup><sup>s</sup>* <sup>C</sup> (*g*, *fi*) <sup>&</sup>lt; *<sup>ε</sup>* whenever *<sup>i</sup>* <sup>≥</sup> *<sup>i</sup>*<sup>0</sup> and ∑<sup>∞</sup> *<sup>n</sup>*=*n*0+<sup>1</sup> <sup>2</sup>−*<sup>n</sup>* <sup>1</sup> *fi* <sup>0</sup> (*n*) <sup>&</sup>lt; *<sup>ε</sup>*. Whence

$$\begin{aligned} \sum\_{n=n\_0+1}^{\infty} 2^{-n} \frac{1}{g(n)} &= \sum\_{n=n\_0+1}^{\infty} 2^{-n} \left( \frac{1}{g(n)} - \frac{1}{f\_{\bar{i}\_0}(n)} + \frac{1}{f\_{\bar{i}\_0}(n)} \right) \\ &\le \sum\_{n=n\_0+1}^{\infty} 2^{-n} \left| \frac{1}{g(n)} - \frac{1}{f\_{\bar{i}\_0}(n)} \right| + \sum\_{n=n\_0+1}^{\infty} 2^{-n} \frac{1}{f\_{\bar{i}\_0}(n)} \\ &\le 2d\_{\mathcal{C}}^{\mathbf{s}}(g\_{\mathcal{I}}f\_{\bar{i}\_0}) + \sum\_{n=n\_0+1}^{\infty} 2^{-n} \frac{1}{f\_{\bar{i}\_0}(n)} \\ &< 3\varepsilon. \end{aligned}$$

Now suppose for the purpose of contradiction that *g* ∈ C / *<sup>c</sup>*,*k*. Then there exists *n*<sup>1</sup> ∈ **N** with <sup>1</sup> <sup>≤</sup> *<sup>n</sup>*<sup>1</sup> <sup>≤</sup> *<sup>k</sup>* such that *<sup>g</sup>*(*n*1) �<sup>=</sup> *cn*<sup>1</sup> . Put *<sup>ε</sup>* <sup>=</sup> <sup>2</sup>−*n*<sup>1</sup> <sup>|</sup> <sup>1</sup> *<sup>g</sup>*(*n*1) <sup>−</sup> <sup>1</sup> *cn*1 |. Then there exists *i*<sup>0</sup> ∈ **N** such that *ds* <sup>C</sup> (*g*, *fi*) <sup>&</sup>lt; *<sup>ε</sup>* <sup>2</sup> whenever *i* ≥ *i*0. Thus

$$\sum\_{n=1}^{\infty} 2^{-n} \left| \frac{1}{g(n)} - \frac{1}{f\_i(n)} \right| < \varepsilon\_\nu$$

whenever *i* ≥ *i*0. As a result we have that

$$\varepsilon = 2^{-n\_1} |\frac{1}{g(n\_1)} - \frac{1}{c\_{n\_1}}| \le \sum\_{n=1}^{\infty} 2^{-n} \left| \frac{1}{g(n)} - \frac{1}{f\_{i\_0}(n)} \right| < \varepsilon\_\epsilon$$

which is a contradiction. So *g*(*n*) = *cn* for all 1 ≤ *n* ≤ *k*. Therefore we have shown that C*c*,*k ds* <sup>C</sup> <sup>=</sup> <sup>C</sup>*c*,*<sup>k</sup>* and, thus, that <sup>C</sup>*c*,*<sup>k</sup>* is closed in (C, *<sup>d</sup><sup>s</sup>* <sup>C</sup> ).

Since the metric space (C, *<sup>d</sup><sup>s</sup>* <sup>C</sup> ) is complete and, by Proposition 3, the subset <sup>C</sup>*c*,*<sup>k</sup>* is closed in (C, *<sup>d</sup><sup>s</sup>* <sup>C</sup> ) we immediately obtain the following consequence.

**Corollary 4.** *The quasi-metric space* (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ) *is bicomplete.*

The next result provides the existence and uniqueness of solution to a recurrence equation of type (12).

**Theorem 5.** *The functional* <sup>Ψ</sup>*<sup>T</sup> is contractive from* (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ) *into itself with contractive constant*

$$\left(\max\_{1 \le i \le k} \frac{1}{a\_i}\right) \left(\frac{2^k - 1}{2^k}\right) \dots$$

**Proof.** Let *f* , *g* ∈ C*c*,*k*. Then we prove that

$$\operatorname{sd}\_{\mathcal{C}}|\_{\mathcal{C}\_{\mathcal{C}k}}(\Psi\_T(f)\_{\prime}, \Psi\_T(\mathfrak{g})) \le \operatorname{sd}\_{\mathcal{C}}|\_{\mathcal{C}\_{\mathcal{C}k}}(f, \mathfrak{g})\_{\prime}$$

where

12 Will-be-set-by-IN-TECH

Furthermore, we prove that in order to provide the complexity class of an algorithm whose running time satisfies a recurrence equation of type (12) is enough to search among all complexity functions for which the functional associated to the recurrence equation is an improver and a worsener simultaneously. Finally, with the aim, on one hand, to validate our new results and, on the other hand, to show the potential applicability of the developed theory to Asymptotic Complexity Analysis, we end the section discussing the complexity class

C*c*,*<sup>k</sup>* = { *f* ∈ C : *f*(*n*) = *cn* for all 1 ≤ *n* ≤ *k*}.

It is clear that a complexity function in C*c*,*<sup>k</sup>* is a solution to a recurrence equation of type (12)

The next result is useful to supply the bicompleteness of the quasi-metric space (C*c*,*k*, *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* ).

C ).

1

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

∞ <sup>∑</sup>*n*=*n*0+<sup>1</sup>

Now suppose for the purpose of contradiction that *g* ∈ C / *<sup>c</sup>*,*k*. Then there exists *n*<sup>1</sup> ∈ **N** with

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

*fi*(*n*)

 < *ε*,

*fi*<sup>0</sup> (*n*) <sup>+</sup>

 +

*fi*<sup>0</sup> (*n*)

<sup>2</sup>−*<sup>n</sup>* <sup>1</sup> *fi*<sup>0</sup> (*n*)

1 *fi*<sup>0</sup> (*n*)

∞ <sup>∑</sup>*n*=*n*0+<sup>1</sup>

*cn* if 1 <sup>≤</sup> *<sup>n</sup>* <sup>≤</sup> *<sup>k</sup>*

*<sup>i</sup>*=<sup>1</sup> *ai <sup>f</sup>*(*<sup>n</sup>* <sup>−</sup> *<sup>i</sup>*) + *<sup>h</sup>*(*n*) if *<sup>n</sup>* <sup>&</sup>gt; *<sup>k</sup>* , (13)

<sup>C</sup> (*g*, *fi*) = 0. First of all we prove that

<sup>2</sup>−*<sup>n</sup>* <sup>1</sup> *fi*<sup>0</sup> (*n*)


<sup>C</sup> (*g*, *fi*) <sup>&</sup>lt; *<sup>ε</sup>* whenever *<sup>i</sup>* <sup>≥</sup> *<sup>i</sup>*<sup>0</sup> and

of the running time of Fibonacci.

for all *f* ∈ C*c*,*k*.

**Proof.** Let *g* ∈ C*c*,*<sup>k</sup>*

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

*fi*

∞ <sup>∑</sup>*n*=*n*0+<sup>1</sup>

∑<sup>∞</sup>

*ds*

<sup>C</sup> (*g*, *fi*) <sup>&</sup>lt; *<sup>ε</sup>*

**4.1 The fixed point: existence and uniqueness of solution**

Fix *k* ∈ **N**. Consider the subset C*c*,*<sup>k</sup>* of C given by

Ψ*T*(*f*)(*n*) =

if and only if it is a fixed point of the functional Ψ*T*.

**Proposition 3.** *The subset* <sup>C</sup>*c*,*<sup>k</sup> is closed in* (C, *<sup>d</sup><sup>s</sup>*

<sup>0</sup> (*n*) <sup>&</sup>lt; *<sup>ε</sup>*. Whence

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

<sup>1</sup> <sup>≤</sup> *<sup>n</sup>*<sup>1</sup> <sup>≤</sup> *<sup>k</sup>* such that *<sup>g</sup>*(*n*1) �<sup>=</sup> *cn*<sup>1</sup> . Put *<sup>ε</sup>* <sup>=</sup> <sup>2</sup>−*n*<sup>1</sup> <sup>|</sup> <sup>1</sup>

<sup>2</sup> whenever *i* ≥ *i*0. Thus

*ds*

∑*k*

<sup>C</sup> and (*fi*)*i*∈**<sup>N</sup>** ⊂ C*c*,*<sup>k</sup>* with lim*i*→<sup>∞</sup> *<sup>d</sup><sup>s</sup>*

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

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

<sup>C</sup> (*g*, *fi*<sup>0</sup> ) +

∞ <sup>∑</sup>*n*=*n*0+<sup>1</sup>

∞ <sup>∑</sup>*n*=*n*0+<sup>1</sup>

*<sup>g</sup>* ∈ C. Indeed, given *<sup>ε</sup>* <sup>&</sup>gt; 0, there exist *<sup>i</sup>*0, *<sup>n</sup>*<sup>0</sup> <sup>∈</sup> **<sup>N</sup>** such that *<sup>d</sup><sup>s</sup>*

≤

<sup>≤</sup> <sup>2</sup>*d<sup>s</sup>*

< 3*ε*.

∞ ∑ *n*=1 2−*<sup>n</sup>* 1 *<sup>g</sup>*(*n*) <sup>−</sup> <sup>1</sup>

Define the functional Ψ*<sup>T</sup>* : C*c*,*<sup>k</sup>* −→ C*c*,*<sup>k</sup>* by

$$s = (\max\_{1 \le i \le k} \frac{1}{a\_i}) \left( \frac{2^k - 1}{2^k} \right).$$

Indeed, we have that

$$\begin{split} d\_{\mathcal{C}}|\_{\mathcal{C},\downarrow}(\Psi\_{T}(f),\Psi\_{T}(g)) &= \sum\_{n=1}^{\infty} 2^{-n} \max\left(\frac{1}{\Psi\_{T}(g)(n)} - \frac{1}{\Psi\_{T}(f)(n)}, 0\right) \\ &= \sum\_{n=k+2}^{\infty} 2^{-n} \max\left(\frac{\sum\_{i=1}^{k} a\_{i} \left(f(n-i) - g(n-i)\right)}{r(n)}, 0\right) \\ &\leq \sum\_{n=k+2}^{\infty} 2^{-n} \max\left(\frac{\sum\_{i=1}^{k} a\_{i} \left(f(n-i) - g(n-i)\right)}{\sum\_{i=1}^{k} a\_{i}^{2} \left(g(n-i)f(n-i)\right)}, 0\right) \\ &\leq \left(\max\_{1\leq i\leq k} \frac{1}{a\_{i}}\right) \sum\_{n=k+2}^{\infty} 2^{-n} \max\left(\sum\_{i=1}^{k} \frac{1}{g(n-i)} - \frac{1}{f(n-i)}, 0\right) \\ &\leq \left(\max\_{1\leq i\leq k} \frac{1}{a\_{i}}\right) \sum\_{n=k+1}^{\infty} 2^{-n} \left(\frac{2^{k}-1}{2^{k}}\right) \max\left(\frac{1}{g(n)} - \frac{1}{f(n)}, 0\right) \\ &= \left(\max\_{1\leq i\leq k} \frac{1}{a\_{i}}\right) \left(\frac{2^{k}-1}{2^{k}}\right) d\_{C}|\_{C\_{i}}(f,g), \end{split}$$

From statements in Lemma 6 we infer, such as it was pointed out in (Romaguera et al., 2011), that to provide an asymptotic upper bound of the running time of computing of an algorithm whose running time matches up with the fixed point of a contractive mapping Ψ : *C* −→ *C* (*C* ⊆ C) associated to a recurrence equation is enough to check if such a mapping satisfies the condition Ψ(*g*) ≤ *g* for any complexity function even if Ψ is not monotone (see Section 3). This fact presents an improvement of our new method over the Schellekens one. So in the remainder of this paper, and according to (Romaguera et al., 2011), given *C* ⊆ C and a contraction Ψ : *C* −→ *C* we will say that Ψ is a cont-improver with respect to a complexity function *g* ∈ *C* provided that Ψ(*g*) ≤ *g*. Note that the contractivity of the functional implies that a cont-improver is an improver. Consequently, a cont-improver is a transformation on algorithms in such a way that the application of the transformation yields, from a complexity

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

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

Motivated by statement 2) in Lemma 6, it was introduced a new kind of functionals called worseners. For our subsequent purpose, let us recall that, given *C* ⊆ C, a contraction Ψ : *C* −→ *C* is called a *worsener* with respect to a function *f* ∈ *C* provided that *f* ≤ Ψ(*f*). An easy verification shows that if a functional <sup>Ψ</sup> is a worsener with respect to *<sup>f</sup>* , then <sup>Ψ</sup>*n*−1(*f*) <sup>≤</sup> <sup>Ψ</sup>*n*(*f*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**. Hence the computational meaning of a worsener functional is dual to the meaning of a cont-improver. Indeed, a worsener is a functional which corresponds to a transformation on algorithms in such a way that the application of the transformation yields,

The next result provides the method to provide the asymptotic upper and lower bounds of the running time of computing of those algorithms whose running time of computing is the

**Theorem 7.** *Let fT* ∈ C*c*,*<sup>k</sup> be the (unique) solution to a recurrence equation of type (12). Then the*

*1) If the functional* Ψ*<sup>T</sup> associated to (12), and given by (13), is a cont-improver with respect to some*

*2) If the functional* Ψ*<sup>T</sup> associated to (12), and given by (13), is a worsener with respect to some*

**Proof.** Assume that Ψ*<sup>T</sup>* is a cont-improver with respect to *g* ∈ C*c*,*k*. Then we have Ψ*T*(*g*) ≤ *g*. Hence we obtain that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (Ψ*T*(*g*), *<sup>g</sup>*) = 0. It immediately follows, by statement 1) in Lemma

To prove 2) suppose that Ψ*<sup>T</sup>* is a worsener with respect to *g* ∈ C*c*,*k*. Then *g* ≤ Ψ*T*(*g*). Whence we deduce that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*g*, <sup>Ψ</sup>*T*(*g*)) = 0. Thus statement 2) in Lemma 6 gives that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*g*, *fT*) = 0, and we conclude that *fT* ∈ Ω(*g*). This finishes the proof. In the light of Theorem 7, we have that the solution to a recurrence equation of type (12) satisfies that *fT* ∈ O(*g*) ∩ Ω(*h*) whenever Ψ*<sup>T</sup>* is a cont-improver and a worsener with respect to *g* ∈ C*c*,*<sup>k</sup>* and *h* ∈ C*c*,*k*, respectively. Consequently we obtain the complexity class of algorithms whose running time of computing satisfies a recurrence equation of type (12) when there exist *l* ∈ C*c*,*k*, *r*, *t* > 0 and *n*<sup>0</sup> ∈ **N** such that *g*(*n*) = *rl*(*n*) and *h* = *tl*(*n*) for all *n* ≥ *n*<sup>0</sup> and, besides, Ψ*<sup>T</sup>* is a cont-improver and a worsener with respect to *g* and *h* respectively, because,

6, that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*fT*, *<sup>g</sup>*) = 0 and, thus, *fT* ∈ O(*g*). So we have proved 1).

point of view, an improved algorithm.

from a complexity point of view, a worsened algorithm.

solution to a recurrence equation of type (12).

*function g* ∈ C*c*,*k, then fT* ∈ O(*g*).

*function g* ∈ C*c*,*k, then fT* ∈ Ω(*g*)*.*

*following facts hold:*

in such a case, *fT* ∈ Θ(*l*).

where

$$r(n) = \left(h(n)\right)^2 + h(n)\sum\_{i=1}^k a\_i \left(f(n-i) + g(n-i)\right) + \left(\sum\_{i=1}^k a\_i f(n-i)\right) \cdot \left(\sum\_{i=1}^k a\_i g(n-i)\right),$$

for all *n* > *k*.

Now the existence and uniqueness of the fixed point *fT* ∈ C*c*,*<sup>k</sup>* of Ψ*<sup>T</sup>* follow from Corollary 4 and Theorem 1, because (max1≤*i*≤*<sup>k</sup>* 1 *ai* ) <sup>2</sup>*<sup>k</sup>*−<sup>1</sup> 2*k* < 1.

Since *fT* ∈ C*c*,*<sup>k</sup>* is the solution to a the recurrence equation of type (12) if and only if *fT* is a fixed point of Ψ*T*, Theorem 5 yields that a recurrence of the form (12) has a unique solution *fT* in <sup>C</sup>*c*,*k*. Moreover, note that, by Theorem 1, we have that lim*n*→<sup>∞</sup> <sup>Ψ</sup>*<sup>n</sup> <sup>T</sup>*(*g*) = *fT* in (C*c*,*k*, *<sup>d</sup><sup>s</sup>*|C*c*,*<sup>k</sup>* ) for all *g* ∈ C*c*,*k*.

#### **4.2 Bounding the solution: the complexity class of running time of computing**

In order to describe the complexity of those recursive algorithms whose running time of computing satisfies a recurrence equation of type (12) we need recall the below auxiliary result which was announced without proof in (Romaguera et al., 2011) with the aim of extending Schellekens fixed point technique and, thus, analyze the complexity class of those algorithms whose running time of computing holds a recurrence equation of type (8) .

**Lemma 6.** *Let C be a subset of* C *such that the quasi-metric space* (*C*, *<sup>d</sup>*<sup>C</sup> |*C*) *is bicomplete and suppose that* Ψ : *C* −→ *C is a contractive functional with fixed point f* ∈ *C and contractive constant s. Then the following statements hold:*


**Proof.** <sup>1</sup>) Assume that there exists *<sup>g</sup>* ∈ *<sup>C</sup>* such that *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = 0. Suppose for the purpose of contradiction that *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) > 0. Then we have that

$$\begin{split} d\_{\mathcal{C}}|\_{\mathbb{C}}(f,\mathcal{g}) &\leq d\_{\mathcal{C}}|\_{\mathbb{C}}(f,\Psi(\mathcal{g})) + d\_{\mathcal{C}}|\_{\mathbb{C}}(\Psi(\mathcal{g}),\mathcal{g}) = d\_{\mathcal{C}}|\_{\mathbb{C}}(f,\Psi(\mathcal{g})) \\ &\leq d\_{\mathcal{C}}|\_{\mathbb{C}}(f,\Psi(f)) + d\_{\mathcal{C}}|\_{\mathbb{C}}(\Psi(f),\Psi(\mathcal{g})) \\ &= d\_{\mathcal{C}}|\_{\mathbb{C}}(\Psi(f),\Psi(\mathcal{g})) \leq s d\_{\mathcal{C}}|\_{\mathbb{C}}(f,\mathcal{g}). \end{split}$$

From the preceding inequality we deduce that 1 ≤ *s*, which contradicts the fact that *s* is a contractive constant. So *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) = 0.

2) The thesis of 2) can be proved applying similar arguments to those given in the proof of 1). 

Observe that if a complexity function *f* represents the running time of computing of an algorithm under study, the fact that there exists a complexity function *g* satisfying the condition *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = 0 (*d*<sup>C</sup> |*C*(*g*, <sup>Ψ</sup>(*g*)) = 0) in the preceding lemma provides an asymptotic upper (lower) bound of the aforesaid running time, since *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) = <sup>0</sup> (*d*<sup>C</sup> |*C*(*g*, *<sup>f</sup>*) = 0) implies that *<sup>f</sup>* ∈ O(*g*) (*<sup>f</sup>* ∈ <sup>Ω</sup>(*g*)).

14 Will-be-set-by-IN-TECH

Now the existence and uniqueness of the fixed point *fT* ∈ C*c*,*<sup>k</sup>* of Ψ*<sup>T</sup>* follow from Corollary 4

Since *fT* ∈ C*c*,*<sup>k</sup>* is the solution to a the recurrence equation of type (12) if and only if *fT* is a fixed point of Ψ*T*, Theorem 5 yields that a recurrence of the form (12) has a unique solution *fT*

In order to describe the complexity of those recursive algorithms whose running time of computing satisfies a recurrence equation of type (12) we need recall the below auxiliary result which was announced without proof in (Romaguera et al., 2011) with the aim of extending Schellekens fixed point technique and, thus, analyze the complexity class of those algorithms

**Lemma 6.** *Let C be a subset of* C *such that the quasi-metric space* (*C*, *<sup>d</sup>*<sup>C</sup> |*C*) *is bicomplete and suppose that* Ψ : *C* −→ *C is a contractive functional with fixed point f* ∈ *C and contractive constant s. Then*

**Proof.** <sup>1</sup>) Assume that there exists *<sup>g</sup>* ∈ *<sup>C</sup>* such that *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = 0. Suppose for the purpose

*<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) ≤ *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , <sup>Ψ</sup>(*g*)) + *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , <sup>Ψ</sup>(*g*)) ≤ *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , <sup>Ψ</sup>(*f*)) + *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*f*), <sup>Ψ</sup>(*g*)) = *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*f*), <sup>Ψ</sup>(*g*)) ≤ *sd*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*).

From the preceding inequality we deduce that 1 ≤ *s*, which contradicts the fact that *s* is a

2) The thesis of 2) can be proved applying similar arguments to those given in the proof of 1).

Observe that if a complexity function *f* represents the running time of computing of an algorithm under study, the fact that there exists a complexity function *g* satisfying the condition *<sup>d</sup>*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = 0 (*d*<sup>C</sup> |*C*(*g*, <sup>Ψ</sup>(*g*)) = 0) in the preceding lemma provides an asymptotic upper (lower) bound of the aforesaid running time, since *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) = <sup>0</sup>

 *k* ∑ *i*=1

*ai f*(*n* − *i*)

 · *k* ∑ *i*=1

< 1.

*aig*(*n* − *i*)

*<sup>T</sup>*(*g*) = *fT* in (C*c*,*k*, *<sup>d</sup><sup>s</sup>*|C*c*,*<sup>k</sup>* )

 ,

*ai* (*f*(*n* − *i*) + *g*(*n* − *i*)) +

1 *ai* ) <sup>2</sup>*<sup>k</sup>*−<sup>1</sup> 2*k* 

in <sup>C</sup>*c*,*k*. Moreover, note that, by Theorem 1, we have that lim*n*→<sup>∞</sup> <sup>Ψ</sup>*<sup>n</sup>*

**4.2 Bounding the solution: the complexity class of running time of computing**

whose running time of computing holds a recurrence equation of type (8) .

*1) If there exists g* ∈ *C with d*<sup>C</sup> |*C*(Ψ(*g*), *<sup>g</sup>*) = 0, *then d*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) = 0. *2) If there exists g* ∈ *C with d*<sup>C</sup> |*C*(*g*, <sup>Ψ</sup>(*g*)) = 0, *then d*<sup>C</sup> |*C*(*g*, *<sup>f</sup>*) = 0.

of contradiction that *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) > 0. Then we have that

contractive constant. So *<sup>d</sup>*<sup>C</sup> |*C*(*<sup>f</sup>* , *<sup>g</sup>*) = 0.

(*d*<sup>C</sup> |*C*(*g*, *<sup>f</sup>*) = 0) implies that *<sup>f</sup>* ∈ O(*g*) (*<sup>f</sup>* ∈ <sup>Ω</sup>(*g*)).

where

for all *n* > *k*.

for all *g* ∈ C*c*,*k*.

*r*(*n*)=(*h*(*n*))<sup>2</sup> + *h*(*n*)

*the following statements hold:*

and Theorem 1, because (max1≤*i*≤*<sup>k</sup>*

*k* ∑ *i*=1 From statements in Lemma 6 we infer, such as it was pointed out in (Romaguera et al., 2011), that to provide an asymptotic upper bound of the running time of computing of an algorithm whose running time matches up with the fixed point of a contractive mapping Ψ : *C* −→ *C* (*C* ⊆ C) associated to a recurrence equation is enough to check if such a mapping satisfies the condition Ψ(*g*) ≤ *g* for any complexity function even if Ψ is not monotone (see Section 3). This fact presents an improvement of our new method over the Schellekens one. So in the remainder of this paper, and according to (Romaguera et al., 2011), given *C* ⊆ C and a contraction Ψ : *C* −→ *C* we will say that Ψ is a cont-improver with respect to a complexity function *g* ∈ *C* provided that Ψ(*g*) ≤ *g*. Note that the contractivity of the functional implies that a cont-improver is an improver. Consequently, a cont-improver is a transformation on algorithms in such a way that the application of the transformation yields, from a complexity point of view, an improved algorithm.

Motivated by statement 2) in Lemma 6, it was introduced a new kind of functionals called worseners. For our subsequent purpose, let us recall that, given *C* ⊆ C, a contraction Ψ : *C* −→ *C* is called a *worsener* with respect to a function *f* ∈ *C* provided that *f* ≤ Ψ(*f*). An easy verification shows that if a functional <sup>Ψ</sup> is a worsener with respect to *<sup>f</sup>* , then <sup>Ψ</sup>*n*−1(*f*) <sup>≤</sup> <sup>Ψ</sup>*n*(*f*) for all *<sup>n</sup>* <sup>∈</sup> **<sup>N</sup>**. Hence the computational meaning of a worsener functional is dual to the meaning of a cont-improver. Indeed, a worsener is a functional which corresponds to a transformation on algorithms in such a way that the application of the transformation yields, from a complexity point of view, a worsened algorithm.

The next result provides the method to provide the asymptotic upper and lower bounds of the running time of computing of those algorithms whose running time of computing is the solution to a recurrence equation of type (12).

**Theorem 7.** *Let fT* ∈ C*c*,*<sup>k</sup> be the (unique) solution to a recurrence equation of type (12). Then the following facts hold:*


**Proof.** Assume that Ψ*<sup>T</sup>* is a cont-improver with respect to *g* ∈ C*c*,*k*. Then we have Ψ*T*(*g*) ≤ *g*. Hence we obtain that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (Ψ*T*(*g*), *<sup>g</sup>*) = 0. It immediately follows, by statement 1) in Lemma 6, that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*fT*, *<sup>g</sup>*) = 0 and, thus, *fT* ∈ O(*g*). So we have proved 1).

To prove 2) suppose that Ψ*<sup>T</sup>* is a worsener with respect to *g* ∈ C*c*,*k*. Then *g* ≤ Ψ*T*(*g*). Whence we deduce that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*g*, <sup>Ψ</sup>*T*(*g*)) = 0. Thus statement 2) in Lemma 6 gives that *<sup>d</sup>*<sup>C</sup> |C*c*,*<sup>k</sup>* (*g*, *fT*) = 0, and we conclude that *fT* ∈ Ω(*g*). This finishes the proof.

In the light of Theorem 7, we have that the solution to a recurrence equation of type (12) satisfies that *fT* ∈ O(*g*) ∩ Ω(*h*) whenever Ψ*<sup>T</sup>* is a cont-improver and a worsener with respect to *g* ∈ C*c*,*<sup>k</sup>* and *h* ∈ C*c*,*k*, respectively. Consequently we obtain the complexity class of algorithms whose running time of computing satisfies a recurrence equation of type (12) when there exist *l* ∈ C*c*,*k*, *r*, *t* > 0 and *n*<sup>0</sup> ∈ **N** such that *g*(*n*) = *rl*(*n*) and *h* = *tl*(*n*) for all *n* ≥ *n*<sup>0</sup> and, besides, Ψ*<sup>T</sup>* is a cont-improver and a worsener with respect to *g* and *h* respectively, because, in such a case, *fT* ∈ Θ(*l*).

**5. Asymptotic Complexity Analysis and Denotational Semantics via a common**

and Denotational Semantics for Recursive Programs Based on Complexity Spaces

Valero, 2009) , (Romaguera & Valero, 2011b) and (Romaguera et al., 2011a).

denotational specification introduced in Section 1, that is

the following recurrence equation (Boxer and Miller, 2005):

whose construction is as follows:

(*X*, *<sup>d</sup>*, *<sup>x</sup>*0) is the quasi-metric space (C*X*,*x*<sup>0</sup> , *<sup>d</sup>*C*X*,*x*<sup>0</sup>

C*X*,*x*<sup>0</sup> = { *f* : **N** −→ *X* :

As we have pointed out in Sections 1 and 3, the main objective of Schellekens' work was to apply the fixed point technique of the Scott approach for Denotational Semantics to Asymptotic Complexity Analysis. After accomplishing the original aim, he suggested the possibility of giving applications of the complexity space framework to new realms of Computer Science as, in particular, to Denotational Semantics. Thus, the research line began by Schellekens would have benefited from the fundamentals of Denotational Semantics (concretely from Scott's ideas) and, at the same time, the latter would benefit from the ideas and techniques that could be originated in the context of the complexity space. In this direction, a few fruitful interactions between both research disciplines have recently been shown in (Romaguera & Valero, 2008), (Rodríguez-López et al., 2008), (Llull-Chavarría &

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

In this section we go more deeply into the relationship between both aforenamed disciplines and present a unified mathematical structure that will be helpful in Asymptotic Complexity Analysis and Denotational Semantics simultaneously. For this purpose, consider a recursive algorithm computing the factorial of a nonnegative integer number by means of the recursive

*f act*(*n*) = <sup>1</sup> if *<sup>n</sup>* <sup>=</sup> <sup>1</sup>

It is clear that the running time of computing of such a recursive algorithm is the solution to

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

where *c*, *d* > 0. In the light of the preceding recursive specifications, our objective is to be able to describe simultaneously under a unique fixed point technique the running time of computing and the meaning of the recursive algorithm that computes the factorial of a nonnegative integer number, that is to provide the complexity class of the solution to the recurrence equation (15) and to prove that the unique solution to the denotational specification (14) is the entire factorial function. To this end we will need to recall the following facts.

On one hand, in (Romaguera & Schellekens, 2000) S. Romaguera and Schellekens introduced and studied a new complexity space setting, that we will call generalized complexity spaces,

Given a quasi-metric space (*X*, *d*) and a fixed *x*<sup>0</sup> ∈ *X*, the generalized complexity space of

∞ ∑ *n*=1

), where

2<sup>−</sup>*nds*

(*x*0, *f*(*n*)) < ∞},

*nf act*(*<sup>n</sup>* <sup>−</sup> <sup>1</sup>) if *<sup>n</sup>* <sup>≥</sup> <sup>2</sup> . (14)

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

**mathematical framework**

#### **4.3 An application to Asymptotic Complexity Analysis: Fibonacci case**

In this subsection we validate the developed theory and illustrate the potential applicability of the obtained results by means of providing the asymptotic complexity class of the recursive algorithm that computes the Fibonacci sequence, an algorithm whose running time of computing can be analyzed neither via the technique exposed in (Schellekens, 1995) nor via its extended version given in (Romaguera et al., 2011).

As we have exposed above, the running time of computing of Fibonacci is the solution to the below recurrence equation:

$$T(n) = \begin{cases} 2c & \text{if } n = 1 \\ 3c & \text{if } n = 2 \\ T(n-1) + T(n-2) + 4c & \text{if } n > 2 \end{cases}$$

where *c* > 0. Clearly, this recurrence equation can be retrieved from (12) as a particular case when we fix *k* = 2, *a*<sup>1</sup> = *a*<sup>2</sup> = 1, *c*<sup>1</sup> = 2*c*, *c*<sup>2</sup> = 3*c* and *h*(*n*) = 4*c* for all *n* ∈ **N**. Then, taking

$$\Psi\_T(f)(n) = \begin{cases} 2c & \text{if } n = 1 \\ 3c & \text{if } n = 2 \\ f(n-1) + f(n-2) + 4c \text{ if } n > 2 \end{cases} $$

for all *f* ∈ C*c*,2, Theorem 5 guarantees the existence and uniqueness of the solution in C*c*,2, say *f F <sup>T</sup>* , to the above recurrence equation in such a way that it matches up with the running time of computing of the recursive algorithm under consideration.

Next, fix *r* > 0 and *α* > <sup>1</sup> <sup>2</sup> and define the function *hα*,*<sup>r</sup>* by

$$h\_{\alpha,r}(n) = \begin{cases} 2c & \text{if } n = 1 \\ 3c & \text{if } n = 2 \\ r\alpha^n & \text{if } n > 2 \end{cases}.$$

Since *α* > <sup>1</sup> <sup>2</sup> , the D'Alembert ratio test guarantees that *h<sup>α</sup>* ∈ C*c*,2.

It is not hard to see that Ψ*<sup>T</sup>* is a cont-improver with respect to the complexity function *h<sup>α</sup>* (i.e. <sup>Ψ</sup>*T*(*hα*) <sup>≤</sup> *<sup>h</sup>α*) if and only if *<sup>α</sup>* <sup>≥</sup> 1.61 and *<sup>r</sup>* <sup>≥</sup> <sup>4</sup>*<sup>c</sup> <sup>α</sup>*<sup>2</sup> . Hence we obtain, by statement 1) in Theorem 7, that the running of Fibonacci holds *f <sup>F</sup> <sup>T</sup>* ∈ O(*h*1.61, <sup>4</sup>*<sup>c</sup> α*2 ).

Moreover, a straightforward computation shows that at Ψ*<sup>T</sup>* is a worsener with respect to the complexity function *hα*,*<sup>r</sup>* (i.e. *hα*,*<sup>r</sup>* ≤ Ψ*T*(*hα*,*r*)) if and only if *α* ≤ 1.61 (*r* is not subject to any constraint). Thus we deduce, by statement 2) in Theorem 7, that *f <sup>F</sup> <sup>T</sup>* ∈ Ω(*h*1.61, <sup>4</sup>*<sup>c</sup> α*2 ).

Therefore we obtain that *f <sup>F</sup> <sup>T</sup>* ∈ Θ(*h*1.61, <sup>4</sup>*<sup>c</sup> α*2 ), which agrees with the complexity class that can be found in the literature for the recursive algorithm under study, i.e. *f <sup>F</sup> <sup>T</sup>* <sup>∈</sup> <sup>Θ</sup>((1.61)*n*) (Cull et al., 1985).

16 Will-be-set-by-IN-TECH

In this subsection we validate the developed theory and illustrate the potential applicability of the obtained results by means of providing the asymptotic complexity class of the recursive algorithm that computes the Fibonacci sequence, an algorithm whose running time of computing can be analyzed neither via the technique exposed in (Schellekens, 1995) nor via

As we have exposed above, the running time of computing of Fibonacci is the solution to the

where *c* > 0. Clearly, this recurrence equation can be retrieved from (12) as a particular case when we fix *k* = 2, *a*<sup>1</sup> = *a*<sup>2</sup> = 1, *c*<sup>1</sup> = 2*c*, *c*<sup>2</sup> = 3*c* and *h*(*n*) = 4*c* for all *n* ∈ **N**. Then, taking

for all *f* ∈ C*c*,2, Theorem 5 guarantees the existence and uniqueness of the solution in C*c*,2, say

*<sup>T</sup>* , to the above recurrence equation in such a way that it matches up with the running time

⎧ ⎪⎪⎨

⎪⎪⎩

It is not hard to see that Ψ*<sup>T</sup>* is a cont-improver with respect to the complexity function *h<sup>α</sup>* (i.e.

*<sup>T</sup>* ∈ O(*h*1.61, <sup>4</sup>*<sup>c</sup>*

Moreover, a straightforward computation shows that at Ψ*<sup>T</sup>* is a worsener with respect to the complexity function *hα*,*<sup>r</sup>* (i.e. *hα*,*<sup>r</sup>* ≤ Ψ*T*(*hα*,*r*)) if and only if *α* ≤ 1.61 (*r* is not subject to any

2*c* if *n* = 1 3*c* if *n* = 2 *T*(*n* − 1) + *T*(*n* − 2) + 4*c* if *n* > 2

2*c* if *n* = 1 3*c* if *n* = 2 *f*(*n* − 1) + *f*(*n* − 2) + 4*c* if *n* > 2

> 2*c* if *n* = 1 3*c* if *n* = 2 *rα<sup>n</sup>* if *n* > 2

> > *α*2 ).

.

,

,

*<sup>α</sup>*<sup>2</sup> . Hence we obtain, by statement 1) in Theorem

), which agrees with the complexity class that can be

*<sup>T</sup>* ∈ Ω(*h*1.61, <sup>4</sup>*<sup>c</sup>*

*α*2 ).

*<sup>T</sup>* <sup>∈</sup> <sup>Θ</sup>((1.61)*n*) (Cull et

**4.3 An application to Asymptotic Complexity Analysis: Fibonacci case**

its extended version given in (Romaguera et al., 2011).

*T*(*n*) =

Ψ*T*(*f*)(*n*) =

of computing of the recursive algorithm under consideration.

<sup>Ψ</sup>*T*(*hα*) <sup>≤</sup> *<sup>h</sup>α*) if and only if *<sup>α</sup>* <sup>≥</sup> 1.61 and *<sup>r</sup>* <sup>≥</sup> <sup>4</sup>*<sup>c</sup>*

7, that the running of Fibonacci holds *f <sup>F</sup>*

Therefore we obtain that *f <sup>F</sup>*

⎧ ⎪⎪⎨

⎪⎪⎩

⎧ ⎪⎪⎨

⎪⎪⎩

<sup>2</sup> and define the function *hα*,*<sup>r</sup>* by

*hα*,*r*(*n*) =

<sup>2</sup> , the D'Alembert ratio test guarantees that *h<sup>α</sup>* ∈ C*c*,2.

constraint). Thus we deduce, by statement 2) in Theorem 7, that *f <sup>F</sup>*

*<sup>T</sup>* ∈ Θ(*h*1.61, <sup>4</sup>*<sup>c</sup>*

found in the literature for the recursive algorithm under study, i.e. *f <sup>F</sup>*

*α*2

below recurrence equation:

Next, fix *r* > 0 and *α* > <sup>1</sup>

*f F*

Since *α* > <sup>1</sup>

al., 1985).
