Asymptotic complexity of algorithms: Difference between revisions

From Algowiki
Jump to navigation Jump to search
Line 19: Line 19:
# For a selection of <math>k</math> characterizing parameters for an [[Algorithms and correctness#Algorithmic problem|algorithmic problem]], let <math>\mathcal{I}(n_1,\ldots,n_k)</math> denote the set of all instances for which these parameters assume the values <math>n_1,\ldots,n_k</math>.
# For a selection of <math>k</math> characterizing parameters for an [[Algorithms and correctness#Algorithmic problem|algorithmic problem]], let <math>\mathcal{I}(n_1,\ldots,n_k)</math> denote the set of all instances for which these parameters assume the values <math>n_1,\ldots,n_k</math>.
# For an [[Algorithms and correctness#Algorithm|algorithm]] for this algorithmic problem,  the '''asymptotic complexity''' of the algorithm with respect to this selection of characterizing parameters is defined as follows.
# For an [[Algorithms and correctness#Algorithm|algorithm]] for this algorithmic problem,  the '''asymptotic complexity''' of the algorithm with respect to this selection of characterizing parameters is defined as follows.
## In the '''worst case''': by the function <math>f:\mathbb{N}^k\rightarrow\mathbb{R}^+</math> such that <math>f(n_1,\ldots,n_k)</math> is the ''maximum'' number of operations executed for any instance is <math>\mathcal{I}(n_1,\ldots,n_k)</math>.
## In the '''worst case''': by the function <math>f:\mathbb{N}^k\rightarrow\mathbb{R}^+</math> such that <math>f(n_1,\ldots,n_k)</math> is the ''maximum'' number of operations executed by the algorithm for any instance is <math>\mathcal{I}(n_1,\ldots,n_k)</math>.
## In the '''best case''': by the function <math>f:\mathbb{N}^k\rightarrow\mathbb{R}^+</math> such that <math>f(n_1,\ldots,n_k)</math> is the ''minimum'' number of operations executed for any instance is <math>\mathcal{I}(n_1,\ldots,n_k)</math>.
## In the '''best case''': by the function <math>f:\mathbb{N}^k\rightarrow\mathbb{R}^+</math> such that <math>f(n_1,\ldots,n_k)</math> is the ''minimum'' number of operations executed by the algorithm for any instance is <math>\mathcal{I}(n_1,\ldots,n_k)</math>.
## In the '''average case''':
## In the '''average case''':



Revision as of 12:29, 28 May 2015

Corresponding page on the original wiki (to be ported asap):

http://huffmann.algo.informatik.tu-darmstadt.de/wiki/wiki.algo.informatik.tu-darmstadt.de/index.php/Asymptotic_complexity_of_algorithms.html

Asymptotic complexity vs. run time

Roughly speaking, the run time of an algorithm is measured by the number of operations executed by the machine. However, in theoretical considerations, the run time is estimated by the algorithm's asymptotic complexity. In asymptotic considerations, constant multiplicative factors are completely disregarded. Therefore, it does not matter how fast the machine and how smart the algorithm's implementation is.

Characterizing parameters

For the inputs of an algorithmic problem, one or more characterizing (numerical) parameters are to be selected, from which the total size of an input can be computed (or, at least, quite tightly bounded from above and from below).

Examples:

  1. The number of elements in sets, maps, and sequences and the (maximum) size of an element in a set, map, or sequence.
  2. The number of nodes and the number of edges/arcs in a graph.

Asymptotic complexity

  1. For a selection of [math]\displaystyle{ k }[/math] characterizing parameters for an algorithmic problem, let [math]\displaystyle{ \mathcal{I}(n_1,\ldots,n_k) }[/math] denote the set of all instances for which these parameters assume the values [math]\displaystyle{ n_1,\ldots,n_k }[/math].
  2. For an algorithm for this algorithmic problem, the asymptotic complexity of the algorithm with respect to this selection of characterizing parameters is defined as follows.
    1. In the worst case: by the function [math]\displaystyle{ f:\mathbb{N}^k\rightarrow\mathbb{R}^+ }[/math] such that [math]\displaystyle{ f(n_1,\ldots,n_k) }[/math] is the maximum number of operations executed by the algorithm for any instance is [math]\displaystyle{ \mathcal{I}(n_1,\ldots,n_k) }[/math].
    2. In the best case: by the function [math]\displaystyle{ f:\mathbb{N}^k\rightarrow\mathbb{R}^+ }[/math] such that [math]\displaystyle{ f(n_1,\ldots,n_k) }[/math] is the minimum number of operations executed by the algorithm for any instance is [math]\displaystyle{ \mathcal{I}(n_1,\ldots,n_k) }[/math].
    3. In the average case:

Input size and polynomial complexity

The size of an input is the

For a given input,