2

Does there exist an algorithm for which an exact complexity provably cannot be expressed in closed-form?

Here closed-form means a finite composition of addition, subtraction, product, division, factorial, power with any exponent, logarithm, trigonometric function, inverse trigonometric function, hyperbolic function, and inverse hyperbolic function. You may choose a subset of the above functions to allow in a closed-form expression; this makes the problem easier. However, the larger the set of allowed functions, the better, since this also answers the problem for the subsets.

Exact complexity is a function from the input-set to a real number. You may group the input by some property, and then study exact worst-case complexity instead (or exact best-case complexity).

Any computational model will do, as well as counting any resource (e.g. number of comparisons). To close off a trivial solution, a function without a closed-form expression cannot be a primitive operation of the computational model.

If yes, is there a simple example of such an algorithm?

kaba
  • 451
  • 4
  • 9

4 Answers4

4

The runtime of an algorithm that computes the Ackermann function can't be expressed using primitive recursive functions. All commonly known named functions (well, besides the Ackermann function) are primitive recursive as far as I know.

adrianN
  • 5,991
  • 19
  • 27
4

Here's a trivial example of an algorithm whose running time has no closed form:

let x = f(n)
while x >= 0: x := x - 1

where n is the parameter and f is a function with no closed form and with a running time that has a closed form.

It's always possible to construct an algorithm with any (computable) running time. There are as many ways as you like to do nothing. Sure, this isn't the optimal way to do nothing, but we don't limit the study of algorithms to optimal algorithms. In fact, we need to evaluate the complexity of an algorithm before we can say whether it's optimal.

Gilles 'SO- stop being evil'
  • 44,159
  • 8
  • 120
  • 184
0

You can always find the exact number of operations by simulating the algorithm and counting all operations. If you accept that as "closed form" then obviously you can give the exact number of operations for any algorithm.

If not, then I assume that you would want to know if it is possible, after careful human analysis of the algorithm, write a program that looks at any input for the algorithm, and within reasonable time and without simulating the algorithm calculates a reasonable approximation for the running time of the algorithm for that input.

Take a simple algorithm like Quicksort. You choose a pivot, and the choice of the pivot, good or bad, massively affects the runtime. It is possible that some input data always produces a really bad choice of the pivot, and excessive runtime. Even if you introduce a pseudo-random generator to pick the pivot, there's still the possibility of excessive runtime. To give a decent approximation for the runtime for some input, you don't really have any choice but simulating the algorithm.

Well, there's probably someone more clever than me, and maybe it is possible to analyse Quicksort, but then Quicksort is a very simple algorithm.

PS. The OP has now stated that he wants the running time of an algorithm based on some simple parameter. That's nonsense. He's not going to get that. Again the example Quicksort: The runtime depends on the exact ordering of the values in the array in a highly complex way. For any implementation, I can produce an array that maximises the running time, and a single change of one item in that array total changes it.

gnasher729
  • 32,238
  • 36
  • 56
0

There are plenty of simple algorithms whose running-time is unknown in any form. Therefore, their "complexity" can not be expressed in closed-form either, for suitable notions of "closed-form".

Note that, ironically, some unknown running-time functions may have closed forms in the rather vague sense of "using commonly used names for things" since some famous unknown quantities have been given names.

Raphael
  • 73,212
  • 30
  • 182
  • 400