Math 2.0

Computer science Definition

Analysis of algorithms

Builds on AlgorithmBig O notationTime complexity

Definition

Let ๐’œ\mathcal{A} be an algorithm with input set II, and let โˆฃxโˆฃโˆˆโ„•\abs{x} \in \N be the size of an input xโˆˆIx \in I. Let c(x)c(x) be the number of elementary steps of ๐’œ\mathcal{A} on xx in a fixed cost model. Let In={xโˆˆI:โˆฃxโˆฃ=n}I_n = \set{x \in I : \abs{x} = n} and assume each InI_n is finite and nonempty.

  1. The worst-case running time of ๐’œ\mathcal{A} is T(n)=maxโกxโˆˆInc(x)T(n) = \max_{x \in I_n} c(x).
  2. The best-case running time is B(n)=minโกxโˆˆInc(x)B(n) = \min_{x \in I_n} c(x).
  3. Given a probability distribution Prโกn\Pr_n on each InI_n, the average-case running time is Tห‰(n)=โˆ‘xโˆˆInPrโกn(x)โ€‰c(x)\bar{T}(n) = \sum_{x \in I_n} \Pr_n(x)\, c(x).

The analysis of algorithms is the determination of such functions, usually up to asymptotic order as nโ†’โˆžn \to \infty. The same definitions with memory use in place of c(x)c(x) give the space complexity.

Remarks

Example: linear search for a key in a list of nn items, counting comparisons, has T(n)=nT(n) = n and B(n)=1B(n) = 1. If the key is present and equally likely to be at each of the nn positions, then Tห‰(n)=1nโˆ‘k=1nk=n+12\bar{T}(n) = \frac{1}{n}\sum_{k=1}^n k = \frac{n+1}{2}. In asymptotic terms, T(n)=ฮ˜(n)T(n) = \Theta(n), Tห‰(n)=ฮ˜(n)\bar{T}(n) = \Theta(n) and B(n)=ฮ˜(1)B(n) = \Theta(1).

The time complexity of a problem is a different notion: it is the least running time of an algorithm that solves the problem.

Reading path

To understand this page from the ground up, read these 4 pages in order. The foundations come first.

Show the path as a graph
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Algorithm concept
  2. Big O notation concept
  3. Time complexity concept
  4. Analysis of algorithms definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Analysis_of_algorithms
About this page
Tag45P7W927P5
URIm2://45P7W927P5
Kinddefinition
WritingW0 stub
MSC68W40, 68Q25
DefinesAnalysis of algorithms
UsesAlgorithm, Big O notation, Time complexity
Changed3 November 2026

Markdown ยท JSON ยท Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.