Subquadratic time

Subquadratic time

In computing an algorithm is said to run in subquadratic time if its running time f(n) is less then o(n^2).

For example, most naïve sorting algorithms are quadratic (e.g., insertion sort), but more advanced algorithms can be found that are subquadratic (e.g., merge sort). No general-purpose sorts run in linear time, but the change from quadratic to the common O(nln n) is of great practical importance.

Since Big O notation essentially captures how well an algorithm scales, subquadratic algorithms scale to higher problem sizes much better than algorithms of quadratic or higher complexity. For example, say we have two algorithms (call them A and B) which compute a function f(n). Algorithm A computes f in 10n log_2(n) + 3n + 4 steps, rounded up, (making it an O(n log (n)) algorithm, and algorithm B comptutes it in n^2 + 2n + 1 steps, making it a quadratic (O(n^2)) algorithm.

In this case, algorithm B outperforms algorithm A for all integer values of n < 61. On the other hand, for n=100, the quadratic algorithm is doing 46% more work than the O(n log (n)) algorithm, and the difference becomes even more dramatic for higher values of n. By the time n=1000, the quadratic algorithm is doing almost 10 times the work of the subquadratic algorithm.

See also: Big O notation


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Time complexity — In computer science, the time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the size of the input to the problem. The time complexity of an algorithm is commonly expressed using big O… …   Wikipedia

  • subquadratic — adjective Describing an algorithm that runs in greater than linear, but less than quadratic time Syn: linearithmic, quasilinear …   Wiktionary

  • 3SUM — In computational complexity theory, 3SUM is the following computational problem conjectured to require roughly quadratic time::Given a set S of n integers, are there elements a , b , c in S such that a + b + c = 0?There is a simple algorithm to… …   Wikipedia

  • List of computability and complexity topics — This is a list of computability and complexity topics, by Wikipedia page. Computability theory is the part of the theory of computation that deals with what can be computed, in principle. Computational complexity theory deals with how hard… …   Wikipedia

  • Median graph — The median of three vertices in a median graph In mathematics, and more specifically graph theory, a median graph is an undirected graph in which any three vertices a, b, and c have a unique median: a vertex m(a,b,c) that belongs to shortest… …   Wikipedia

  • List of mathematics articles (S) — NOTOC S S duality S matrix S plane S transform S unit S.O.S. Mathematics SA subgroup Saccheri quadrilateral Sacks spiral Sacred geometry Saddle node bifurcation Saddle point Saddle surface Sadleirian Professor of Pure Mathematics Safe prime Safe… …   Wikipedia

  • Grafo mediano — El mediano de tres vértices en un grafo mediano. En matemática, y más específicamente en la teoría de grafos, un grafo mediano es un grafo no dirigido en que cualesquiera tres vértices a, b, y c tienen un único mediano. Un mediano es un vértice… …   Wikipedia Español

  • Dehn function — In the mathematical subject of geometric group theory, a Dehn function, named after Max Dehn, is an optimal function associated to a finite group presentation which bounds the area of a relation in that group (that is a freely reduced word in the …   Wikipedia

  • Block Wiedemann algorithm — The Block Wiedemann algorithm for computing kernel vectors of a matrix over a finite field is a generalisation of an algorithm due to Don Coppersmith. Coppersmith s algorithm Let M be an n imes n square matrix over some finite field F, let x… …   Wikipedia

  • Van Kampen diagram — In the mathematical area of geometric group theory, a van Kampen diagram is a planar diagram used to represent the fact that a particular word among the generators of a group given by a group presentation represents the identity element in that… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”