Complexity of algorithms
(extendable essay)

1

The concept of the complexity of an algorithm is measured as the time or storage space cost required to execute it in the worst or average case. This concept provides a mathematical definition for the rather vague term "hardness," which is sometimes used to characterize algorithms.

:

When an algorithm is considered from the point of view of complexity, it is assumed that, at its possible inputs , we are given the nonnegative integer function , which is known as the input size, and nonnegative integer time and space cost functions , (space cost is also known as memory storage cost; the cost required for storing the input itself is ignored).

:

For a fixed input size, the inputs of an algorithm can vary, in which case the cost generally varies as well. The worst-case time and space complexities of an algorithm are functions of numerical argument defined as

The range of regarded as an argument of and is the range of the size .

The worst-case complexity determines a tight upper bound for the possible cost of the algorithm on inputs of given size. It cannot be ruled out that in some cases this bound is rather large, while inputs corresponding to the worst case are rarely encountered among all inputs of given size.

T

2

:

When discussing average-case complexity, we consider only the situation when, for each fixed input size , the corresponding inputs form a finite set . Assume that each is assigned some probability : and . Thus, the time and space cost functions and of an algorithm on inputs of size are random variables on . The average-case time and space complexities of are defined as the expectations of the corresponding random variables:

:

Given an arbitrary algorithm for any probability distribution on the set , the average-case complexity does not exceed the worst-case complexity: , .

If an algorithm is repeatedly applied to inputs of given size, it can be expected that the arithmetic mean of the costs is close to the average-case complexity of this algorithm. However, it is assumed in this case that the inputs of given size are appropriately assigned some probabilities, while this assumption has to be justified (the typical assumption that all the inputs of each size are equiprobable may appear groundless in a particular situation).

[ ]

T

3

+

As was discussed above, the worst- and average-case complexities of an algorithm are both a function of a numerical argument-the input size. The growth of the complexity of a particular algorithm with increasing input size is frequently analyzed using asymptotic bounds of the form

The first of them is an upper asymptotic bound, the second is a lower asymptotic bound, and the third combines the first two and can be put in words as follows: “ is on the order of ”, or “ and are of the same order”.

+

A comparison of the complexities of different algorithms based on their asymptotic complexity bounds can be made not for all types of such bounds. For example, if algorithms and have respective complexities such that , , it cannot be concluded that for all sufficiently large .

[ ]

T

4

:

We can consider different complexities according to the costs taken into account. Suppose that a time cost function gives the number of operations of some type, assuming that they require an identical runtime independent of the operand size and set equal to 1. Then we obtain an algebraic complexity measured as the number of operations of the given type.

:

Bit time complexity is obtained when the number of bit operations is used as a cost function. In a similar fashion, the space algebraic and bit space complexities can be defined using the number of operations values of the considered type.

T

5

+

The concept of complexity is also considered in the case of randomized algorithms, i.e., algorithms making calls to a random number generator with a known distribution.

+

Generally, the cost of a randomized algorithm is not uniquely determined by its input, but also depends on the generated random numbers. However, the averaged cost for each particular input gives a scalar numeric function on the set of inputs. As a result, the complexity of an algorithm can be treated following the general definition of complexity.

As was previously discussed, the average-case complexity of a "usual" (deterministic) algorithm is of interest only if correct assumptions are made about the probability of occurrence of one or another input. The considered complexity of randomized algorithms is worst-case complexity but it is determined by the averaged costs. Nevertheless, this averaging can be trusted, since randomized algorithms make use of random number generators in which the probability distribution is fixed and independent of the inputs.

[ ]

T

6

In computational complexity theory, initial assumptions are made about a hypothetical computing device (known as a model of computation).

+

A random-access machine (RAM) is used as such a model in some cases, while a Turing machine is chosen in other cases.

The former model is closer to actual devices, while the latter is more formalized, which is frequently useful in the existence analysis of an algorithm with certain complexity properties.

We will use the RAM model. The assumption that the size of a cell is unlimited leads to algebraic complexity, while the assumption that one bit is stored in a cell leads to time or space bit complexity.

7

[ ]

The considered concept of complexity is sometimes referred to as computational complexity (its possible special cases are algebraic and bit complexities) in order to distinguish it from descriptive complexity, which is somehow defined relying on the code of an algorithm.

Only computational complexity is discussed below, and we continue to refer to it as complexity.

8

+

Considering a class of algorithms for solving a problem yields a family of functions that are complexities (for example, time complexities) of algorithms in this class. Accordingly, we can discuss a lower bound for this family and the existence of a minimal function in it.

+

If there is a minimal function in this family, then the corresponding algorithm is optimal in the considered class of algorithms.

T

9

:

Optimal algorithms in a given class are not always known. It is also possible that a given class has no optimal algorithm, i.e., an algorithm whose complexity is a lower complexity bound for algorithms in this class.

:

Rather frequently, it is very difficult to answer whether a particular class of algorithms has one whose complexity does not grow too fast with increasing input size.

:

For some classes of algorithms, a difficult question is whether there exists an algorithm in such a class with complexity bounded above by a polynomial whose form is not specified (such an algorithm is known as polynomial-time).

+

In particular, many unanswered questions concern polynomial-time algorithms for decision problems, i.e., those having a yes/no solution, or a 1/0 solution, etc. In this context, we mention the well-known P≟NP problem.

T

10

When we examine the existence of an algorithm of "not very high" complexity, an important role is played by the reducibility of one problem to another. The possibility of quickly solving some problem can imply the same possibility for a number of other problems and, on the contrary, if a certain problem cannot be quickly solved, the same can automatically be implied for a number of other problems.

+

Considering linear reducibility, we can rigorously define the fact that one computational problem is not harder than another.

+

Polynomial reducibility means that, if a computational problem is solvable by a polynomial-time algorithm, then another problem is also solvable by a polynomial-time algorithm.

T

11

:

Along with various questions concerning the possible limits for algorithms from one or another class, always important are problems associated with complexity bounds for particular algorithms. Frequently, trivial upper and lower bounds are easy to derive, while deriving close-to-tight bounds for an algorithm requires much effort and nontrivial approaches.

T