Misplaced Pages

Time complexity: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 14:59, 2 July 2014 editAnomieBOT (talk | contribs)Bots6,575,396 editsm Dating maintenance tags: {{Citation needed span}}← Previous edit Latest revision as of 11:17, 17 December 2024 edit undoCipherRephic (talk | contribs)Extended confirmed users2,327 edits Reverting edit(s) by 27.5.8.222 (talk) to rev. 1263346995 by OAbot: Vandalism (RW 16.1)Tags: RW Undo 
(484 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
{{Short description|Estimate of time taken for running an algorithm}}
{{Redirect|Running time|the film|Running Time (film)}}
{{Redirect-distinguish|Running time|Running Time (film)}}
{{Refimprove|date=January 2010}}
], showing the number of operations ''N'' as the result of input size ''n'' for each function]]
In ], the '''time complexity''' of an ] quantifies the amount of time taken by an algorithm to run as a function of the length of the ] representing the input<ref name=Sipser />{{RP|226}}. The time complexity of an algorithm is commonly expressed using ], which excludes coefficients and lower order terms. When expressed this way, the time complexity is said to be described ''asymptotically'', i.e., as the input size goes to infinity. For example, if the time required by an algorithm on all inputs of size ''n'' is at most {{nowrap|1=5''n''<sup>3</sup> + 3''n''}}, the asymptotic time complexity is O(''n''<sup>3</sup>).


Time complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, where an elementary operation takes a fixed amount of time to perform. Thus the amount of time taken and the number of elementary operations performed by the algorithm differ by at most a constant factor. In ], the '''time complexity''' is the ] that describes the amount of computer time it takes to run an ]. Time complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, supposing that each elementary operation takes a fixed amount of time to perform. Thus, the amount of time taken and the number of elementary operations performed by the algorithm are taken to be related by a ].


Since an algorithm's running time may vary among different inputs of the same size, one commonly considers the ], which is the maximum amount of time required for inputs of a given size. Less common, and usually specified explicitly, is the ], which is the average of the time taken on inputs of a given size (this makes sense because there are only a finite number of possible inputs of a given size). In both cases, the time complexity is generally expressed as a ] of the size of the input.<ref name="Sipser" />{{RP|226}} Since this function is generally difficult to compute exactly, and the running time for small inputs is usually not consequential, one commonly focuses on the behavior of the complexity when the input size increases—that is, the ] of the complexity. Therefore, the time complexity is commonly expressed using ], typically {{nowrap|<math>O(n)</math>,}} {{nowrap|<math>O(n\log n)</math>,}} {{nowrap|<math>O(n^\alpha)</math>,}} {{nowrap|<math>O(2^n)</math>,}} etc., where {{mvar|n}} is the size in units of ]s needed to represent the input.
Since an algorithm's performance time may vary with different inputs of the same size, one commonly uses the ] of an algorithm, denoted as '''''T''(''n'')''', which is defined as the maximum amount of time taken on any input of size ''n''. Time complexities are classified by the nature of the function ''T''(''n''). For instance, an algorithm with ''T''(''n'') = O(''n'') is called a linear time algorithm, and an algorithm with ''T''(''n'') = O(2<sup>''n''</sup>) is said to be an exponential time algorithm.


Algorithmic complexities are classified according to the type of function appearing in the big O notation. For example, an algorithm with time complexity <math>O(n)</math> is a ''linear time algorithm'' and an algorithm with time complexity <math>O(n^\alpha)</math> for some constant <math>\alpha > 0</math> is a ''polynomial time algorithm''.
==Table of common time complexities==

== Table of common time complexities ==
{{Further|Computational complexity of mathematical operations}} {{Further|Computational complexity of mathematical operations}}
The following table summarizes some classes of commonly encountered time complexities. In the table, poly(''x'')&nbsp;=&nbsp;''x''<sup>''O''(1)</sup>, i.e., polynomial in ''x''. The following table summarizes some classes of commonly encountered time complexities. In the table, {{nowrap|1=poly(''x'') = ''x''<sup>''O''(1)</sup>}}, i.e., polynomial in&nbsp;''x''.


{| class="wikitable" {| class="wikitable sortable"
|- |-
! Name !! ] !! Running time (''T''(''n'')) !! Examples of running times !! Example algorithms ! Name !! ] !! Time complexity {{nowrap|({{math|''O''(''n'')}})}} !! Examples of running times !! Example algorithms
|- |-
| constant time || || ''O''(1) || 10 || Determining if an integer (represented in binary) is even or odd | constant time || || <math>O(1)</math> || 10 || Finding the median value in a sorted ] of numbers. Calculating {{math|(−1){{sup|''n''}}}}.
|- |-
| ] time || || ''O''(α(n)) || || ] per operation using a ] | ] time || || <math>O\bigl(\alpha(n)\bigr)</math> || || ] per operation using a ]
|- |-
| ]ic time || || ''O''({{log-star}}&nbsp;''n'') || || ] | ]ic time || || <math>O(\log^*n)</math> || || ]
|- |-
| log-logarithmic || || ''O''(log log ''n'') || || Amortized time per operation using a bounded ]<ref>{{Cite journal|first1=Kurt |last1=Mehlhorn |first2=Stefan |last2=Naher|year=1990|title=Bounded ordered dictionaries in O(log log N) time and O(n) space|journal=Information Processing Letters|doi=10.1016/0020-0190(90)90022-P|volume=35|issue=4|pages=183}}</ref> | log-logarithmic || || <math>O(\log\log n)</math> || || Amortized time per operation using a bounded ]<ref>{{Cite journal|first1=Kurt |last1=Mehlhorn |author1-link=Kurt Mehlhorn|first2=Stefan |last2=Naher|year=1990|title=Bounded ordered dictionaries in {{math|''O''(log log ''N'')}} time and {{math|''O''(''n'')}} space|journal=]|doi=10.1016/0020-0190(90)90022-P|volume=35|issue=4|pages=183–189}}</ref>
|- |-
| logarithmic time || ] || ''O''(log&nbsp;''n'') || log&nbsp;''n'', log(''n''<sup>2</sup>) || ] | logarithmic time || ] || <math>O(\log n)</math> || <math>\log n</math>, <math>\log (n^2)</math> || ]
|- |-
| polylogarithmic time || || poly(log&nbsp;''n'') || (log&nbsp;''n'')<sup>2</sup> || | polylogarithmic time || || <math>\text{poly}(\log n)</math> || <math>(\log n)^2</math> ||
|- |-
|fractional power || || ''O''(''n''<sup>c</sup>) where 0 < c < 1 || ''n<sup>1/2</sup>'', ''n<sup>2/3</sup>'' || Searching in a ] | fractional power || || <math>O(n^c)</math> where <math>0<c<1</math> || <math>n^{\frac{1}{2}}</math>, <math>n^{\frac{2}{3}}</math> || ] in a ]
|- |-
| linear time || || ''O''(''n'') || ''n'' || Finding the smallest item in an unsorted ] | linear time || || <math>O(n)</math> || {{mvar|n}}, <math>2n+5</math> || Finding the smallest or largest item in an unsorted ]. ]. ].
|- |-
| "n log star n" time || || ''O''(''n''&nbsp;{{log-star}}&nbsp;''n'') || || ]'s ] algorithm. | "n log-star n" time || || <math>O(n\log^*n)</math> || || ]'s ] algorithm.
|- |-
| linearithmic time || || ''O''(''n''&nbsp;log&nbsp;''n'') || ''n''&nbsp;log&nbsp;''n'', log ''n''! || Fastest possible ] | linearithmic time || || <math>O(n\log n)</math> || <math>n\log n</math>, <math>\log n!</math> || Fastest possible ]. ].
|- |-
| quasilinear time || || <math>n\text{poly}(\log n)</math> || <math>n\log^2 n</math> || ]
| quadratic time || || ''O''(''n''<sup>2</sup>) || ''n''<sup>2</sup> || ]; ]; ]
|- |-
| cubic time || || ''O''(''n''<sup>3</sup>) || ''n''<sup>3</sup> || Naive multiplication of two ''n''×''n'' matrices. Calculating ]. | quadratic time || || <math>O(n^2)</math> || <math>n^2</math> || ]. ]. ]
|- |-
| cubic time || || <math>O(n^3)</math> || <math>n^3</math> || Naive multiplication of two <math>n\times n</math> matrices. Calculating ].
| polynomial time || ] || 2<sup>''O''(log&nbsp;''n'')</sup> = poly(''n'') || ''n'', ''n''&nbsp;log&nbsp;''n'', ''n''<sup>10</sup></sup> || ] for ]; ]
|- |-
| polynomial time || ] || <math>2^{O(\log n)}=\text{poly}(n)</math> || <math>n^2+n</math>, <math>n^{10}</math> || ] for ]. ]<ref name="tao-aks">{{cite book|title=An epsilon of room, II: Pages from year three of a mathematical blog|last=Tao|first=Terence|publisher=American Mathematical Society|year=2010|isbn=978-0-8218-5280-4|series=Graduate Studies in Mathematics|volume=117|location=Providence, RI|pages=82–86|contribution=1.11 The AKS primality test|doi=10.1090/gsm/117|mr=2780010|author-link=Terence Tao|contribution-url=https://terrytao.wordpress.com/2009/08/11/the-aks-primality-test/}}</ref><ref>{{cite journal | last1 = Lenstra | first1 = H. W. Jr. | author1-link = Hendrik Lenstra | last2 = Pomerance | first2 = Carl | author2-link = Carl Pomerance | doi = 10.4171/JEMS/861 | issue = 4 | journal = ] | mr = 3941463 | pages = 1229–1269 | title = Primality testing with Gaussian periods | url = https://math.dartmouth.edu/~carlp/aks111216.pdf | volume = 21 | year = 2019| hdl = 21.11116/0000-0005-717D-0 | s2cid = 127807021 }}</ref>
| quasi-polynomial time || QP || 2<sup>poly(log&nbsp;''n'')</sup> || ''n''<sup>log&nbsp;log&nbsp;''n''</sup>, ''n''<sup>log&nbsp;''n''</sup> || Best-known O(log<sup>2</sup> ''n'')-] for the directed ].
|- |-
| quasi-polynomial time || QP || <math>2^{\text{poly}(\log n)}</math> || <math>n^{\log \log n}</math>, <math>n^{\log n}</math> || Best-known {{math|''O''(log{{sup|2}}''n'')}}-] for the directed ], best known ] solver,<ref>{{cite book |author = Calude, Cristian S. and Jain, Sanjay and Khoussainov, Bakhadyr and Li, Wei and Stephan, Frank| title = Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing| chapter = Deciding parity games in quasipolynomial time| date = 2017| isbn = 9781450345286| publisher = Association for Computing Machinery| chapter-url = https://doi.org/10.1145/3055399.3055409| doi = 10.1145/3055399.3055409 | pages = 252–263| hdl = 2292/31757| s2cid = 30338402}}</ref> best known ] algorithm
| sub-exponential time<br/>(first definition) || SUBEXP || ''O''(2<sup>''n''<sup>''ε''</sup></sup>) for all ''ε''&nbsp;>&nbsp;0 || ''O''(2<sup>log ''n''<sup>log log ''n''</sup></sup>) || Assuming complexity theoretic conjectures, ] is contained in SUBEXP.<ref name="bpp" />
|- |-
| sub-exponential time<br/>(second definition) || || 2<sup>''o''(''n'')</sup> || 2<sup>''n''<sup>1/3</sup></sup> || Best-known algorithm for ] and ] | sub-exponential time<br />(first definition) || SUBEXP || <math>O(2^{n^\epsilon})</math> for all <math>0<\epsilon <1</math> || || Contains ] unless EXPTIME (see below) equals ].<ref name="bpp" />
|- |-
| exponential time<br/>(with linear exponent) || ] || 2<sup>''O''(''n'')</sup> || 1.1<sup>''n''</sup>, 10<sup>''n''</sup> || Solving the ] using ] | sub-exponential time<br />(second definition) || || <math>2^{o(n)}</math> || <math>2^{\sqrt{n}}</math> ||] for ]
formerly-best algorithm for ]
|- |-
| factorial time || || ''O''(''n''!) || ''n''! || Solving the traveling salesman problem via ] | exponential time<br />(with linear exponent) || ] || <math>2^{O(n)}</math> || <math>1.1^n</math>, <math>10^n</math> || Solving the ] using ]
|- |-
| factorial time || || <math>O(n)! = 2^{O(n \log n)}
| exponential time || ] || 2<sup>poly(''n'')</sup> || 2<sup>''n''</sup>, 2<sup>''n''<sup>2</sup></sup> || Solving ] via ]
</math> || <math>n!, n^n, 2^{n \log n}</math> || Solving the ] via ]
|- |-
| double exponential time || ] || 2<sup>2<sup>poly(''n'')</sup></sup> || 2<sup>2<sup>''n''</sup></sup> || Deciding the truth of a given statement in ] | exponential time || ] || <math>2^{\text{poly}(n)}</math> || <math>2^n</math>, <math>2^{n^2}</math> || Solving ] via ]
|-
| double exponential time || ] || <math>2^{2^{\text{poly}(n)}}</math> || <math>2^{2^n}</math> || Deciding the truth of a given statement in ]
|} |}


==Constant time== == Constant time ==
{{redirect|Constant time|programming technique to avoid a timing attack|Timing attack#Avoidance}}
An algorithm is said to be '''constant time''' (also written as '''O(1)''' time) if the value of ''T''(''n'') is bounded by a value that does not depend on the size of the input. For example, accessing any single element in an ] takes constant time as only one ] has to be performed to locate it. However, finding the minimal value in an unordered array is not a constant time operation as a scan over each ] in the array is needed in order to determine the minimal value. Hence it is a linear time operation, taking O(n) time. If the number of elements is known in advance and does not change, however, such an algorithm can still be said to run in constant time.

Despite the name "constant time", the running time does not have to be independent of the problem size, but an upper bound for the running time has to be bounded independently of the problem size. For example, the task "exchange the values of ''a'' and ''b'' if necessary so that ''a''&le;''b''" is called constant time even though the time may depend on whether or not it is already true that ''a'' ≤ ''b''. However, there is some constant ''t'' such that the time required is always ''at most'' ''t''.

Here are some examples of code fragments that run in constant time:


An algorithm is said to be '''constant time''' (also written as <math display="inline">O(1)</math> time) if the value of <math display="inline">T(n)</math> (the complexity of the algorithm) is bounded by a value that does not depend on the size of the input. For example, accessing any single element in an ] takes constant time as only one ] has to be performed to locate it. In a similar manner, finding the minimal value in an array sorted in ascending order; it is the first element. However, finding the minimal value in an unordered array is not a constant time operation as scanning over each ] in the array is needed in order to determine the minimal value. Hence it is a linear time operation, taking <math display="inline">O(n)</math> time. If the number of elements is known in advance and does not change, however, such an algorithm can still be said to run in constant time.
int index = 5;
int item = list;
'''if''' (condition true) '''then'''
perform some operation that runs in constant time
'''else'''
perform some other operation that runs in constant time
'''for''' i = 1 '''to''' 100
'''for''' j = 1 '''to''' 200
perform some operation that runs in constant time


Despite the name "constant time", the running time does not have to be independent of the problem size, but an upper bound for the running time has to be independent of the problem size. For example, the task "exchange the values of {{mvar|a}} and {{mvar|b}} if necessary so that <math display="inline">a \le b</math>" is called constant time even though the time may depend on whether or not it is already true that <math display="inline">a \le b</math>. However, there is some constant {{mvar|t}} such that the time required is always ''at most'' {{mvar|t}}.
If ''T''(''n'') is O(''any constant value''), this is equivalent to and stated in standard notation as ''T''(''n'') being O(1).


==Logarithmic time== == Logarithmic time ==
{{Further|Logarithmic growth}} {{Further|Logarithmic growth}}
An algorithm is said to take '''logarithmic time''' if ''T''(''n'') = '''O(log ''n'')'''. Due to the use of the ] by computers, the ] is frequently base 2 (that is, log<sub>2</sub> ''n'', sometimes written lg ''n''). However, by the ] for logarithms, log<sub>a</sub> ''n'' and log<sub>b</sub> ''n'' differ only by a constant multiplier, which in big-O notation is discarded; thus O(log ''n'') is the standard notation for logarithmic time algorithms regardless of the base of the logarithm. An algorithm is said to take '''logarithmic time''' when <math>T(n) = O(\log n)</math>. Since <math>\log_a n</math> and <math>\log_b n</math> are related by a ], and such a ] to big O classification, the standard usage for logarithmic-time algorithms is <math>O(\log n)</math> regardless of the base of the logarithm appearing in the expression of {{mvar|T}}.


Algorithms taking logarithmic time are commonly found in operations on ]s or when using ]. Algorithms taking logarithmic time are commonly found in operations on ]s or when using ].


An O(log n) algorithm is considered highly efficient, as the operations per instance required to complete decrease with each instance. An <math>O(\log n)</math> algorithm is considered highly efficient, as the ratio of the number of operations to the size of the input decreases and tends to zero when {{mvar|n}} increases. An algorithm that must access all elements of its input cannot take logarithmic time, as the time taken for reading an input of size {{mvar|n}} is of the order of {{mvar|n}}.


An example of logarithmic time is given by dictionary search. Consider a ] {{math|''D''}} which contains {{mvar|n}} entries, sorted in ]. We suppose that, for <math>1 \le k \le n</math>, one may access the {{mvar|k}}th entry of the dictionary in a constant time. Let <math>D(k)</math> denote this {{mvar|k}}th entry. Under these hypotheses, the test to see if a word {{mvar|w}} is in the dictionary may be done in logarithmic time: consider <math>D\left(\left\lfloor \frac{n}{2} \right\rfloor\right)</math>, where <math>\lfloor\;\rfloor</math> denotes the ]. If <math>w = D\left(\left\lfloor \frac{n}{2} \right\rfloor\right)</math>--that is to say, the word {{mvar|w}} is exactly in the middle of the dictionary--then we are done. Else, if <math>w < D\left(\left\lfloor \frac{n}{2} \right\rfloor\right)</math>--i.e., if the word {{mvar|w}} comes earlier in alphabetical order than the middle word of the whole dictionary--we continue the search in the same way in the left (i.e. earlier) half of the dictionary, and then again repeatedly until the correct word is found. Otherwise, if it comes after the middle word, continue similarly with the right half of the dictionary. This algorithm is similar to the method often used to find an entry in a paper dictionary. As a result, the search space within the dictionary decreases as the algorithm gets closer to the target word.
A very simple example of this type of f(n) is an algorithm that cuts a string in half. It will take O(log n) time (n being the length of the string) since we chop the string in half before each print (we make the assumption that ''console.log'' and ''str.substring'' run in constant time).
This means, in order to increase the number of prints, we have to double the length of the string.


== Polylogarithmic time ==
<syntaxhighlight lang="javascript">
An algorithm is said to run in '''] time''' if its time <math>T(n)</math> is <math>O\bigl((\log n)^k\bigr)</math> for some constant {{mvar|k}}. Another way to write this is <math>O(\log^kn)</math>.
// Function to recursively print the right half of a string
var right = function(str){
var length = str.length;
// Helper function
var help = function(index){
// Recursive Case: Print right half
if(index < length){
// Prints characters from index until the end of the array
console.log(str.substring(index, length));
// Recursive Call: call help on right half
help(Math.ceil((length + index)/2));
}
// Base Case: Do Nothing
}
help(0);
}
</syntaxhighlight>


For example, ] can be solved in polylogarithmic time on a ],<ref>{{cite journal | last1 = Bradford | first1 = Phillip G. | last2 = Rawlins | first2 = Gregory J. E. | last3 = Shannon | first3 = Gregory E. | doi = 10.1137/S0097539794270698 | issue = 2 | journal = ] | mr = 1616556 | pages = 466–490 | title = Efficient matrix chain ordering in polylog time | volume = 27 | year = 1998}}</ref> and ] can be ] in a ] way in <math>O(\log^3n)</math> time per insert/delete operation.<ref>{{cite conference | last1 = Holm | first1 = Jacob | last2 = Rotenberg | first2 = Eva | editor1-last = Makarychev | editor1-first = Konstantin | editor2-last = Makarychev | editor2-first = Yury | editor3-last = Tulsiani | editor3-first = Madhur | editor4-last = Kamath | editor4-first = Gautam | editor5-last = Chuzhoy | editor5-first = Julia | editor5-link = Julia Chuzhoy | arxiv = 1911.03449 | contribution = Fully-dynamic planarity testing in polylogarithmic time | doi = 10.1145/3357713.3384249 | pages = 167–180 | publisher = Association for Computing Machinery | title = Proceedings of the 52nd Annual ACM SIGACT Symposium on Theory of Computing, STOC 2020, Chicago, IL, USA, June 22-26, 2020 | year = 2020| isbn = 978-1-4503-6979-4 }}</ref>
==Polylogarithmic time==
An algorithm is said to run in '''polylogarithmic time''' if ''T''(''n'') = O((log ''n'')<sup>''k''</sup>), for some constant ''k''. For example, matrix chain ordering can be solved in polylogarithmic time on a ].<ref>{{Cite journal| last1=Bradford | first1=Phillip G. | last2=Rawlins | first2=Gregory J. E. | last3=Shannon | first3=Gregory E. | title=Efficient Matrix Chain Ordering in Polylog Time | publisher=] | location=Philadelphia | year=1998 | journal=SIAM Journal on Computing | issn=1095-7111 | volume=27 | issue=2 | pages=466–490 | doi=10.1137/S0097539794270698}}</ref>


==Sub-linear time== == Sub-linear time ==
An algorithm is said to run in '''sub-linear time''' (often spelled '''sublinear time''') if ''T''(''n'') = o(''n''). In particular this includes algorithms with the time complexities defined above, as well as others such as the O(''n''<sup>½</sup>) ] algorithm. An algorithm is said to run in '''sub-linear time''' (often spelled '''sublinear time''') if <math>T(n)=o(n)</math>. In particular this includes algorithms with the time complexities defined above.


The specific term ''sublinear time algorithm'' commonly refers to randomized algorithms that sample a small fraction of their inputs and process them efficiently to ] infer properties of the entire instance.<ref>{{cite journal | last1 = Kumar | first1 = Ravi | last2 = Rubinfeld | first2 = Ronitt | author2-link = Ronitt Rubinfeld | title = Sublinear time algorithms | journal = ] | volume = 34 | issue = 4 | pages = 57–67 | url = http://www.cs.princeton.edu/courses/archive/spr04/cos598B/bib/kumarR-survey.pdf | year = 2003 | doi = 10.1145/954092.954103| s2cid = 65359 }}</ref> This type of sublinear time algorithm is closely related to ] and ].
Typical algorithms that are exact and yet run in sub-linear time use ] (as the NC<sub>1</sub> matrix determinant calculation does), ] (as Grover's search does), or alternatively have guaranteed assumptions on the input structure (as the logarithmic time ] and many tree maintenance algorithms do). However, languages such as the set of all strings that have a 1-bit in the position indicated by the first log(n) bits of the string may depend on every bit of the input and yet be computable in sub-linear time.


Other settings where algorithms can run in sublinear time include:
The specific term ''sublinear time algorithm'' is usually reserved to algorithms that are unlike the above in that they are run over classical serial machine models and are not allowed prior assumptions on the input.<ref>{{Cite journal
| last1 = Kumar | first1 = Ravi
| last2 = Rubinfeld | first2 = Ronitt
| title = Sublinear time algorithms
| journal = SIGACT News
| volume = 34
| issue = 4
| pages = 57–67
| url = http://www.cs.princeton.edu/courses/archive/spr04/cos598B/bib/kumarR-survey.pdf
| year = 2003
| doi=10.1145/954092.954103}}</ref> They are however allowed to be ], and indeed must be randomized for all but the most trivial of tasks.


* ]s that have linear or greater total ] (allowing them to read the entire input), but sub-linear ].
As such an algorithm must provide an answer without reading the entire input, its particulars heavily depend on the access allowed to the input. Usually for an input that is represented as a binary string ''b''<sub>1</sub>,...,''b<sub>k</sub>'' it is assumed that the algorithm can in time O(1) request and obtain the value of ''b<sub>i</sub>'' for any ''i''.
* Algorithms that have ] on the input structure. An important example are operations on ], e.g. ] in a sorted array.
* Algorithms that search for local structure in the input, for example finding a local minimum in a 1-D array (can be solved in <math>O(\log(n))</math> time using a variant of binary search).  A closely related notion is that of ] where the algorithm receives a large input and queries to local information about some valid large output.<ref>{{cite conference
| last1 = Rubinfeld   | first1 = Ronitt   |author1-link = Ronitt Rubinfeld
 | contribution = Local Computation Algorithms
 | doi = 10.1145/3293611.3331587
 | pages = 3
 | title = Proceedings of the 2019 ACM Symposium on Principles of Distributed Computing (PODC)
 | year = 2019
| isbn = 978-1-4503-6217-7   }}</ref>


== Linear time ==
Sub-linear time algorithms are typically randomized, and provide only ] solutions. In fact, the property of a binary string having only zeros (and no ones) can be easily proved not to be decidable by a (non-approximate) sub-linear time algorithm. Sub-linear time algorithms arise naturally in the investigation of ].
An algorithm is said to take '''linear time''', or <math>O(n)</math> time, if its time complexity is <math>O(n)</math>. Informally, this means that the running time increases at most linearly with the size of the input. More precisely, this means that there is a constant {{mvar|c}} such that the running time is at most <math>cn</math> for every input of size {{mvar|n}}. For example, a procedure that adds up all elements of a list requires time proportional to the length of the list, if the adding time is constant, or, at least, bounded by a constant.


Linear time is the best possible time complexity in situations where the algorithm has to sequentially read its entire input. Therefore, much research has been invested into discovering algorithms exhibiting linear time or, at least, nearly linear time. This research includes both software and hardware methods. There are several hardware technologies which exploit ] to provide this. An example is ]. This concept of linear time is used in string matching algorithms such as the ] and ].
==Linear time==
An algorithm is said to take '''linear time''', or '''O(''n'')''' time, if its time complexity is O(''n''). Informally, this means that for large enough input sizes the running time increases linearly with the size of the input. For example, a procedure that adds up all elements of a list requires time proportional to the length of the list. This description is slightly inaccurate, since the running time can significantly deviate from a precise proportionality, especially for small values of ''n''.


== <span id="Linearithmic time"></span> Quasilinear time ==
{{citation needed span|text=Linear time is often viewed as a desirable attribute for an algorithm.|date=July 2014}} Much research has been invested into creating algorithms exhibiting (nearly) linear time or better. This research includes both software and hardware methods. In the case of hardware, some algorithms which, mathematically speaking, can never achieve linear time with standard ]s are able to run in linear time. There are several hardware technologies which exploit ] to provide this. An example is ]. This concept of linear time is used in string matching algorithms such as the ] and ].
An algorithm is said to run in '''quasilinear time''' (also referred to as '''log-linear time''') if <math>T(n)=O(n\log^kn)</math> for some positive constant {{mvar|k}};<ref>{{cite journal | last1 = Naik | first1 = Ashish V. | last2 = Regan | first2 = Kenneth W. | last3 = Sivakumar | first3 = D. | doi = 10.1016/0304-3975(95)00031-Q | issue = 2 | journal = ] | mr = 1355592 | pages = 325–349 | title = On quasilinear-time complexity theory | url = http://www.cse.buffalo.edu/~regan/papers/pdf/NRS95.pdf | volume = 148 | year = 1995| doi-access = free }}</ref> '''linearithmic time''' is the case <math>k=1</math>.<ref>{{cite book | last1 = Sedgewick | first1 = Robert | last2 = Wayne | first2 = Kevin | edition = 4th | page = 186 | publisher = Pearson Education | title = Algorithms | url = https://algs4.cs.princeton.edu/home/ | year = 2011}}</ref> Using ] these algorithms are <math>\tilde{O}(n)</math>. Quasilinear time algorithms are also <math>O(n^{1+\varepsilon })</math> for every constant <math>\varepsilon >0</math> and thus run faster than any polynomial time algorithm whose time bound includes a term <math>n^c</math> for any <math>c>1</math>.


Algorithms which run in quasilinear time include:
==Linearithmic time==
* ], <math>O(n\log^2n)</math>
{{citation needed span|text=A '''linearithmic function''' (] of ''linear'' and ''logarithmic'') is a function of the form ''n'' · log ''n'' (i.e., a ] of a ] and a ]ic term). An algorithm is said to run in '''linearithmic time''' if ''T''(''n'') = '''O(''n'' log ''n'')'''.|date=July 2014}} Thus, a linearithmic term grows faster than a linear term but slower than any polynomial in ''n'' with exponent strictly greater than 1.
* ], <math>O(n\log n)</math>, in its randomized version, has a running time that is <math>O(n\log n)</math> in expectation on the worst-case input. Its non-randomized version has an <math>O(n\log n)</math> running time only when considering average case complexity.
* ], <math>O(n\log n)</math>, ], ], binary tree sort, ], ], etc. in the worst case
* ]s, <math>O(n\log n)</math>
* ] calculation, <math>O(n\log n)</math>


In many cases, the ''n'' · log ''n'' running time is simply the result of performing a Θ(log ''n'') operation ''n'' times. For example, ] creates a ] by inserting each element of the n-sized array one by one. Since the insert operation on a ] takes O(log ''n'') time, the entire algorithm takes linearithmic time. In many cases, the <math>O(n\log n)</math> running time is simply the result of performing a <math>\Theta (\log n)</math> operation {{mvar|n}} times (for the notation, see {{slink|Big O notation|Family of Bachmann–Landau notations}}). For example, ] creates a ] by inserting each element of the {{mvar|n}}-sized array one by one. Since the insert operation on a ] takes <math>O(\log n)</math> time, the entire algorithm takes <math>O(n\log n)</math> time.


]s require at least linearithmic number of comparisons in the worst case because log(''n''!) = Θ(''n'' log ''n''), by ]. They also frequently arise from the ] ''T''(''n'') = 2 ''T''(''n''/2) + O(''n''). ]s require at least <math>\Omega (n\log n)</math> comparisons in the worst case because <math>\log (n!)=\Theta (n\log n)</math>, by ]. They also frequently arise from the ] <math display="inline">T(n) = 2T\left(\frac{n}{2}\right)+O(n)</math>.


== Sub-quadratic time ==
Some famous ]s that run in linearithmic time include:
An ] is said to be '''subquadratic time''' if <math>T(n)=o(n^2)</math>.
*] in the average case
*], ], ], binary tree sort, ], ], etc. in the worst case
*]s
*] calculation


For example, simple, comparison-based ]s are quadratic (e.g. ]), but more advanced algorithms can be found that are subquadratic (e.g. ]). No general-purpose sorts run in linear time, but the change from quadratic to sub-quadratic is of great practical importance.
==Quasilinear time==
{{citation needed span|text=A generalization of linearithmic time is '''quasilinear time'''. An algorithm is said to run in quasilinear time if ''T''(''n'') = '''O(''n'' log<sup>''k''</sup> ''n'')''' for any constant ''k''; linearithmic time is the case ''k''&nbsp;=&nbsp;1.|date=July 2014}} Quasilinear time algorithms are also o(''n''<sup>1+ε</sup>) for every ε > 0, and thus run faster than any polynomial in ''n'' with exponent strictly greater than 1.


== Polynomial time ==
Algorithms which run in quasilinear time, in addition to the linearithmic algorithms listed above, include:
{{main|P (complexity)}}
* ], O(''n'' log<sup>''2''</sup> ''n'')
An algorithm is said to be of '''polynomial time''' if its running time is ]ed by a ] expression in the size of the input for the algorithm, that is, {{nowrap|1=''T''(''n'') = ''O''(''n''<sup>''k''</sup>)}} for some positive constant ''k''.<ref name=Sipser>{{Cite book| last=Sipser | first=Michael | author-link=Michael Sipser | title=Introduction to the Theory of Computation | year=2006 | publisher=Course Technology Inc | isbn=0-619-21764-2 }}</ref><ref>{{Cite book| last=Papadimitriou | first=Christos H. | author-link=Christos H. Papadimitriou | title=Computational complexity | year=1994 | publisher=Addison-Wesley | location=Reading, Mass. | isbn=0-201-53082-1 }}</ref> ] for which a deterministic polynomial-time algorithm exists belong to the ] ''']''', which is central in the field of ]. ] states that polynomial time is a synonym for "tractable", "feasible", "efficient", or "fast".<ref>{{Cite book| last=Cobham | first=Alan | author-link=Alan Cobham (mathematician) | year = 1965 | chapter = The intrinsic computational difficulty of functions | title = Proc. Logic, Methodology, and Philosophy of Science II | publisher = North Holland}}</ref>


Some examples of polynomial-time algorithms:
==Sub-quadratic time==
* The ] sorting algorithm on ''n'' integers performs <math>An^2</math> operations for some constant ''A''. Thus it runs in time <math>O(n^2)</math> and is a polynomial-time algorithm.
An ] is said to be '''subquadratic time''' if ''T''(''n'') = o(''n''<sup>2</sup>).

For example, most naïve comparison-based ]s are quadratic (e.g. ]), but more advanced algorithms can be found that are subquadratic (e.g. ]). No general-purpose sorts run in linear time, but the change from quadratic to sub-quadratic is of great practical importance.

==Polynomial time==
An algorithm is said to be of '''polynomial time''' if its running time is ]ed by a ] in the size of the input for the algorithm, i.e., ''T''(''n'') = O(''n''<sup>''k''</sup>) for some constant ''k''.<ref name=Sipser>{{Cite book| last=Sipser | first=Michael | authorlink=Michael Sipser | coauthors= | title=Introduction to the Theory of Computation | year=2006 | publisher=Course Technology Inc | location= | isbn=0-619-21764-2 | pages=}}</ref><ref>{{Cite book| last=Papadimitriou | first=Christos H. | authorlink=Christos H. Papadimitriou | coauthors= | title=Computational complexity | year=1994 | publisher=Addison-Wesley | location=Reading, Mass. | isbn=0-201-53082-1 | pages=}}</ref> ] for which a deterministic polynomial time algorithm exists belong to the ] ''']''', which is central in the field of ]. ] states that polynomial time is a synonym for "tractable", "feasible", "efficient", or "fast".<ref>{{Cite book| last=Cobham | first=Alan | authorlink=Alan Cobham | year = 1965 | chapter = The intrinsic computational difficulty of functions | title = Proc. Logic, Methodology, and Philosophy of Science II | publisher = North Holland}}</ref>

Some examples of polynomial time algorithms:
* The ] sorting algorithm on ''n'' integers performs at most <math>An^2</math> operations for some constant ''A''. Thus it runs in time <math>O(n^2)</math> and is a polynomial time algorithm.
* All the basic arithmetic operations (addition, subtraction, multiplication, division, and comparison) can be done in polynomial time. * All the basic arithmetic operations (addition, subtraction, multiplication, division, and comparison) can be done in polynomial time.
* ]s in ] can be found in polynomial time. * ]s in ] can be found in polynomial time. In some contexts, especially in ], one differentiates between ''']''' and '''weakly polynomial time''' algorithms.

===Strongly and weakly polynomial time===
<!--] redirects here.-->

In some contexts, especially in ], one differentiates between '''strongly polynomial time''' and '''weakly polynomial time''' algorithms. These two concepts are only relevant if the inputs to the algorithms consist of integers.

Strongly polynomial time is defined in the arithmetic model of computation. In this model of computation the basic arithmetic operations (addition, subtraction, multiplication, division, and comparison) take a unit time step to perform, regardless of the sizes of the operands. The algorithm runs in strongly polynomial time if <ref>{{Cite book| last=Grötschel | first=Martin | coauthors = ], ] | year = 1988 | chapter = Complexity, Oracles, and Numerical Computation| title = Geometric Algorithms and Combinatorial Optimization | publisher = Springer | isbn=0-387-13624-X}}</ref>

# the number of operations in the arithmetic model of computation is bounded by a polynomial in the number of integers in the input instance; and
# the space used by the algorithm is bounded by a polynomial in the size of the input.

Any algorithm with these two properties can be converted to a polynomial time algorithm by replacing the arithmetic operations by suitable algorithms for performing the arithmetic operations on a ]. If the second of the above requirement is not met, then this is not true anymore. Given the integer <math>2^n</math> (which takes up space proportional to n), it is possible to compute <math>2^{2^n}</math>
with n multiplications using ]. However, the space used to represent <math>2^{2^n}</math> is proportional to <math>2^n</math>, and thus exponential rather than polynomial in the space used to represent the input. Hence, it is not possible to carry out this computation in polynomial time on a Turing machine, but it is possible to compute it by polynomially many arithmetic operations.

Conversely, there are algorithms which run in a number of Turing machine steps bounded by a polynomial in the length of binary-encoded input, but do not take a number of arithmetic operations bounded by a polynomial in the number of input numbers. The ] for computing the ] of two integers is one example. Given two integers <math>a</math> and <math>b</math> the running time of the algorithm is bounded by <math>O((\log\ a + \log\ b)^2)</math> Turing machine steps. This is polynomial in the size of a binary representation of <math>a</math> and <math>b</math> as the size of such a representation is roughly <math>\log\ a + \log\ b</math>. At the same time, the number of arithmetic operations cannot be bound by the number of integers in the input (which is constant in this case, there are always only two integers in the input). Due to the latter observation, the algorithm does not run in strongly polynomial time. Its real running time depends on the magnitudes of <math>a</math> and <math>b</math> and not only on the number of integers in the input.


These two concepts are only relevant if the inputs to the algorithms consist of integers.
An algorithm which runs in polynomial time but which is not strongly polynomial is said to run in '''weakly polynomial time'''.<ref>{{Cite book| last=Schrijver | first=Alexander | authorlink = Alexander Schrijver| year = 2003 | chapter = Preliminaries on algorithms and Complexity | title = Combinatorial Optimization: Polyhedra and Efficiency | volume = 1 | publisher = Springer | isbn=3-540-44389-4}}</ref>
A well-known example of a problem for which a weakly polynomial-time algorithm is known, but is not known to admit a strongly polynomial-time algorithm,
is ]. Weakly polynomial-time should not be confused with ].


===Complexity classes=== === Complexity classes ===


The concept of polynomial time leads to several complexity classes in computational complexity theory. Some important classes defined using polynomial time are the following. The concept of polynomial time leads to several complexity classes in computational complexity theory. Some important classes defined using polynomial time are the following.


* ''']''': The ] of ]s that can be solved on a ] in polynomial time. * ''']''': The ] of ]s that can be solved on a ] in polynomial time
* ''']''': The complexity class of decision problems that can be solved on a ] in polynomial time. * ''']''': The complexity class of decision problems that can be solved on a ] in polynomial time
* ''']''': The complexity class of decision problems that can be solved with zero error on a ] in polynomial time. * ''']''': The complexity class of decision problems that can be solved with zero error on a ] in polynomial time
* ''']''': The complexity class of decision problems that can be solved with 1-sided error on a probabilistic Turing machine in polynomial time. * ''']''': The complexity class of decision problems that can be solved with 1-sided error on a probabilistic Turing machine in polynomial time.
* ''']''': The complexity class of decision problems that can be solved with 2-sided error on a probabilistic Turing machine in polynomial time. * ''']''': The complexity class of decision problems that can be solved with 2-sided error on a probabilistic Turing machine in polynomial time
* ''']''': The complexity class of decision problems that can be solved with 2-sided error on a ] in polynomial time. * ''']''': The complexity class of decision problems that can be solved with 2-sided error on a ] in polynomial time


P is the smallest time-complexity class on a deterministic machine which is ] in terms of machine model changes. (For example, a change from a single-tape Turing machine to a multi-tape machine can lead to a quadratic speedup, but any algorithm that runs in polynomial time under one model also does so on the other.) Any given ] will have a complexity class corresponding to the problems which can be solved in polynomial time on that machine. P is the smallest time-complexity class on a deterministic machine which is ] in terms of machine model changes. (For example, a change from a single-tape Turing machine to a multi-tape machine can lead to a quadratic speedup, but any algorithm that runs in polynomial time under one model also does so on the other.) Any given ] will have a complexity class corresponding to the problems which can be solved in polynomial time on that machine.


==Superpolynomial time== == Superpolynomial time ==
An algorithm is said to take '''superpolynomial time''' if ''T''(''n'') is not bounded above by any polynomial. It is ω(''n''<sup>''c''</sup>) time for all constants ''c'', where ''n'' is the input parameter, typically the number of bits in the input. An algorithm is defined to take '''superpolynomial time''' if ''T''(''n'') is not bounded above by any polynomial. Using ], it is ''ω''(''n''<sup>''c''</sup>) time for all constants ''c'', where ''n'' is the input parameter, typically the number of bits in the input.


For example, an algorithm that runs for 2<sup>''n''</sup> steps on an input of size ''n'' requires superpolynomial time (more specifically, exponential time). For example, an algorithm that runs for 2<sup>''n''</sup> steps on an input of size ''n'' requires superpolynomial time (more specifically, exponential time).


An algorithm that uses exponential resources is clearly superpolynomial, but some algorithms are only very weakly superpolynomial. For example, the ] runs for ''n''<sup>O(log log ''n'')</sup> time on ''n''-bit inputs; this grows faster than any polynomial for large enough ''n'', but the input size must become impractically large before it cannot be dominated by a polynomial with small degree. An algorithm that uses exponential resources is clearly superpolynomial, but some algorithms are only very weakly superpolynomial. For example, the ] runs for {{nowrap|''n''<sup>''O''(log log ''n'')</sup>}} time on ''n''-bit inputs; this grows faster than any polynomial for large enough ''n'', but the input size must become impractically large before it cannot be dominated by a polynomial with small degree.


An algorithm that requires superpolynomial time lies outside the ] ''']'''. ] posits that these algorithms are impractical, and in many cases they are. Since the ] is unresolved, no algorithm for an ] problem is currently known to run in polynomial time. An algorithm that requires superpolynomial time lies outside the ] ''']'''. ] posits that these algorithms are impractical, and in many cases they are. Since the ] is unresolved, it is unknown whether ] problems require superpolynomial time.


==Quasi-polynomial time== == Quasi-polynomial time ==
{{main|Quasi-polynomial time}}
'''Quasi-polynomial time''' algorithms are algorithms which run slower than polynomial time, yet not so slow as to be exponential time. The worst case running time of a quasi-polynomial time algorithm is <math>2^{O((\log n)^c)}</math> for some fixed ''c''. The best-known classical algorithm for integer factorization, the ], which runs in time about <math>2^{\tilde{O}(n^{1/3})}</math> is ''not'' quasi-polynomial since the running time cannot be expressed as <math>2^{O((\log n)^c)}</math> for some fixed ''c''. If the constant "c" in the definition of quasi-polynomial time algorithms is equal to 1, we get a polynomial time algorithm, and if it is less than 1, we get a sub-linear time algorithm.
'''Quasi-polynomial time''' algorithms are algorithms whose running time exhibits ], a type of behavior that may be slower than polynomial time but yet is significantly faster than ]. The worst case running time of a quasi-polynomial time algorithm is <math>2^{O(\log^c n)}</math> for some fixed {{nowrap|<math>c > 0</math>.}} When <math>c=1</math> this gives polynomial time, and for <math>c < 1</math> it gives sub-linear time.


Quasi-polynomial time algorithms typically arise in reductions from an ] problem to another problem. For example, one can take an instance of an NP hard problem, say ], and convert it to an instance of another problem B, but the size of the instance becomes <math>2^{O((\log n)^c)}</math>. In that case, this reduction does not prove that problem B is NP-hard; this reduction only shows that there is no polynomial time algorithm for B unless there is a quasi-polynomial time algorithm for 3SAT (and thus all of ]). Similarly, there are some problems for which we know quasi-polynomial time algorithms, but no polynomial time algorithm is known. Such problems arise in approximation algorithms; a famous example is the directed ], for which there is a quasi-polynomial time approximation algorithm achieving an approximation factor of <math>O(\log^3 n)</math> (n being the number of vertices), but showing the existence of such a polynomial time algorithm is an open problem. There are some problems for which we know quasi-polynomial time algorithms, but no polynomial time algorithm is known. Such problems arise in approximation algorithms; a famous example is the directed ], for which there is a quasi-polynomial time approximation algorithm achieving an approximation factor of <math>O(\log^3 n)</math> (''n'' being the number of vertices), but showing the existence of such a polynomial time algorithm is an open problem.


Other computational problems with quasi-polynomial time solutions but no known polynomial time solution include the ] problem in which the goal is to ] in the union of a clique and a ]. Although quasi-polynomially solvable, it has been conjectured that the planted clique problem has no polynomial time solution; this planted clique conjecture has been used as a ] to prove the difficulty of several other problems in computational ], ], and ].<ref>{{cite conference | last1 = Braverman | first1 = Mark | author1-link = Mark Braverman (mathematician) | last2 = Kun-Ko | first2 = Young | last3 = Rubinstein | first3 = Aviad | last4 = Weinstein | first4 = Omri | editor-last = Klein | editor-first = Philip N. | arxiv = 1504.08352 | contribution = ETH hardness for densest-{{mvar|k}}-subgraph with perfect completeness | doi = 10.1137/1.9781611974782.86 | mr = 3627815 | pages = 1326–1341 | publisher = Society for Industrial and Applied Mathematics | title = Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19 | year = 2017| isbn = 978-1-61197-478-2 }}</ref>
The complexity class '''QP''' consists of all problems which have quasi-polynomial time algorithms. It can be defined in terms of ] as follows.<ref>{{ComplexityZoo|Class QP: Quasipolynomial-Time|Q#qp}}</ref>
:<math>\mbox{QP} = \bigcup_{c \in \mathbb{N}} \mbox{DTIME}(2^{(\log n)^c})</math>


The complexity class '''QP''' consists of all problems that have quasi-polynomial time algorithms. It can be defined in terms of ] as follows.<ref>{{ComplexityZoo|Class QP: Quasipolynomial-Time|Q#qp}}</ref>
===Relation to NP-complete problems===
:<math>\mbox{QP} = \bigcup_{c \in \mathbb{N}} \mbox{DTIME} \left(2^{\log^c n}\right)</math>


=== Relation to NP-complete problems ===
In complexity theory, the unsolved ] problem asks if all problems in NP have polynomial-time algorithms. All the best-known algorithms for ] problems like 3SAT etc. take exponential time. Indeed, it is conjectured for many natural NP-complete problems that they do not have sub-exponential time algorithms. Here "sub-exponential time" is taken to mean the second definition presented above. (On the other hand, many graph problems represented in the natural way by adjacency matrices are solvable in subexponential time simply because the size of the input is square of the number of vertices.) This conjecture (for the k-SAT problem) is known as the ].<ref name="ETH">{{Cite journal| last1=Impagliazzo | first1=R. | last2=Paturi | first2=R. | title=On the complexity of k-SAT | publisher=] | year=2001 | journal=Journal of Computer and System Sciences | issn=1090-2724 | volume=62 | issue=2 | pages=367–375 | doi=10.1006/jcss.2000.1727}}</ref> Since it is conjectured that NP-complete problems do not have quasi-polynomial time algorithms, some inapproximability results in the field of ] make the assumption that NP-complete problems do not have quasi-polynomial time algorithms. For example, see the known inapproximability results for the ] problem.


In complexity theory, the unsolved ] problem asks if all problems in NP have polynomial-time algorithms. All the best-known algorithms for ] problems like 3SAT etc. take exponential time. Indeed, it is conjectured for many natural NP-complete problems that they do not have sub-exponential time algorithms. Here "sub-exponential time" is taken to mean the second definition presented below. (On the other hand, many graph problems represented in the natural way by adjacency matrices are solvable in subexponential time simply because the size of the input is the square of the number of vertices.) This conjecture (for the k-SAT problem) is known as the ].<ref name="ETH">{{cite journal | last1 = Impagliazzo | first1 = Russell | author1-link = Russell Impagliazzo | last2 = Paturi | first2 = Ramamohan | doi = 10.1006/jcss.2000.1727 | issue = 2 | journal = ] | mr = 1820597 | pages = 367–375 | title = On the complexity of {{mvar|k}}-SAT | url = https://cseweb.ucsd.edu/~paturi/myPapers/pubs/ImpagliazzoPaturi_2001_jcss.pdf | volume = 62 | year = 2001| doi-access = free }}</ref> Since it is conjectured that NP-complete problems do not have quasi-polynomial time algorithms, some inapproximability results in the field of ] make the assumption that NP-complete problems do not have quasi-polynomial time algorithms. For example, see the known inapproximability results for the ] problem.
==Sub-exponential time==
The term '''sub-exponential time''' is used to express that the running time of some algorithm may grow faster than any polynomial but is still significantly smaller than an exponential. In this sense, problems that have sub-exponential time algorithms are somewhat more tractable than those that only have exponential algorithms. The precise definition of "sub-exponential" is not generally agreed upon,<ref>{{Cite web|url=http://scottaaronson.com/blog/?p=394 |title=A not-quite-exponential dilemma |author=Aaronson, Scott |date=5 April 2009 |work=Shtetl-Optimized |accessdate=2 December 2009}}</ref> and we list the two most widely used ones below.


== {{anchor|subexponential time}}Sub-exponential time ==
===First definition===<!-- ] redirects here -->
The term '''] time''' is used to express that the running time of some algorithm may grow faster than any polynomial but is still significantly smaller than an exponential. In this sense, problems that have sub-exponential time algorithms are somewhat more tractable than those that only have exponential algorithms. The precise definition of "sub-exponential" is not generally agreed upon,<ref>{{Cite web|url=http://scottaaronson.com/blog/?p=394 |title=A not-quite-exponential dilemma |author=Aaronson, Scott |date=5 April 2009 |work=Shtetl-Optimized |access-date=2 December 2009}}</ref> however the two most widely used are below.


===First definition===
A problem is said to be sub-exponential time solvable if it can be solved in running times whose logarithms grow smaller than any given polynomial. More precisely, a problem is in sub-exponential time if for every ε&nbsp;>&nbsp;0 there exists an algorithm which solves the problem in time O(2<sup>n<sup>ε</sup></sup>). The set of all such problems is the complexity class '''SUBEXP''' which can be defined in terms of ] as follows.<ref name="bpp">{{Cite journal| last1=Babai | first1=László | author1-link = László Babai | last2=Fortnow | first2=Lance | author2-link = Lance Fortnow | last3=Nisan | first3=N. | author3-link = Noam Nisan | last4=Wigderson | first4=Avi | author4-link = Avi Wigderson | title=BPP has subexponential time simulations unless EXPTIME has publishable proofs | publisher=] | location=Berlin, New York | year=1993 | journal=Computational Complexity | volume=3 | issue=4 | pages=307–318 | doi=10.1007/BF01275486}}</ref><ref>{{ComplexityZoo|Class SUBEXP: Deterministic Subexponential-Time|S#subexp}}</ref><ref>{{Cite journal| last1=Moser | first1=P. | title=Baire's Categories on Small Complexity Classes | publisher=Springer-Verlag | location=Berlin, New York | year=2003 | journal=] | issn=0302-9743 | pages=333–342}}
<!-- ] redirects here -->
</ref><ref>{{Cite journal| last1=Miltersen | first1=P.B. | title=DERANDOMIZING COMPLEXITY CLASSES | publisher=Kluwer Academic Pub | year=2001 | journal=Handbook of Randomized Computing | page=843}}</ref>

A problem is said to be sub-exponential time solvable if it can be solved in running times whose logarithms grow smaller than any given polynomial. More precisely, a problem is in sub-exponential time if for every {{nowrap|''ε'' > 0}} there exists an algorithm which solves the problem in time ''O''(2<sup>''n''<sup>''ε''</sup></sup>). The set of all such problems is the complexity class '''SUBEXP''' which can be defined in terms of ] as follows.<ref name="bpp">{{Cite journal| last1=Babai | first1=László | author1-link = László Babai | last2=Fortnow | first2=Lance | author2-link = Lance Fortnow | last3=Nisan | first3=N. | author3-link = Noam Nisan | last4=Wigderson | first4=Avi | author4-link = Avi Wigderson | title=BPP has subexponential time simulations unless EXPTIME has publishable proofs | publisher=] | location=Berlin, New York | year=1993 | journal=Computational Complexity | volume=3 | issue=4 | pages=307–318 | doi=10.1007/BF01275486| s2cid=14802332 }}</ref><ref>{{ComplexityZoo|Class SUBEXP: Deterministic Subexponential-Time|S#subexp}}</ref><ref>{{Cite conference| last1=Moser | first1=P. | contribution=Baire's Categories on Small Complexity Classes | publisher=Springer-Verlag | location=Berlin, New York | year=2003 | series=] |editor1=Andrzej Lingas |editor2=Bengt J. Nilsson|title=Fundamentals of Computation Theory: 14th International Symposium, FCT 2003, Malmö, Sweden, August 12-15, 2003, Proceedings| volume=2751 | issn=0302-9743 | pages=333–342| doi=10.1007/978-3-540-45077-1_31 | isbn=978-3-540-40543-6 }}</ref><ref>{{Cite journal| last1=Miltersen | first1=P.B. | title=Derandomizing Complexity Classes | publisher=Kluwer Academic Pub | year=2001 | journal=Handbook of Randomized Computing | volume=9 | page=843| doi=10.1007/978-1-4615-0013-1_19 | series=Combinatorial Optimization | doi-broken-date=1 November 2024 | isbn=978-1-4613-4886-3 }}</ref>


:<math>\text{SUBEXP}=\bigcap_{\varepsilon>0} \text{DTIME}\left(2^{n^\varepsilon}\right)</math> :<math>\text{SUBEXP}=\bigcap_{\varepsilon>0} \text{DTIME}\left(2^{n^\varepsilon}\right)</math>


Note that this notion of sub-exponential is non-uniform in terms of ε in the sense that ε is not part of the input and each ε may have its own algorithm for the problem. This notion of sub-exponential is non-uniform in terms of ''ε'' in the sense that ''ε'' is not part of the input and each ε may have its own algorithm for the problem.


===Second definition=== === Second definition ===
Some authors define sub-exponential time as running times in 2<sup>o(''n'')</sup>.<ref name="ETH" /><ref>{{Cite journal| last1=Kuperberg | first1=Greg | title=A Subexponential-Time Quantum Algorithm for the Dihedral Hidden Subgroup Problem | publisher=] | location=Philadelphia | year=2005 | journal=SIAM Journal on Computing | issn=1095-7111 | volume=35 | issue=1 | page=188 | doi=10.1137/s0097539703436345}}</ref><ref>{{cite arXiv|eprint=quant-ph/0406151v1|author1=Oded Regev|title=A Subexponential Time Algorithm for the Dihedral Hidden Subgroup Problem with Polynomial Space|class=quant-ph|year=2004}}</ref> This definition allows larger running times than the first definition of sub-exponential time. An example of such a sub-exponential time algorithm is the best-known classical algorithm for integer factorization, the ], which runs in time about <math>2^{\tilde{O}(n^{1/3})}</math>, where the length of the input is ''n''. Another example is the best-known algorithm for the ], which runs in time 2<sup>O(√(''n''&nbsp;log&nbsp;''n''))</sup>. Some authors define sub-exponential time as running times in <math>2^{o(n)}</math>.<ref name="ETH" /><ref>{{Cite journal| last1=Kuperberg | first1=Greg | title=A Subexponential-Time Quantum Algorithm for the Dihedral Hidden Subgroup Problem | location=Philadelphia | year=2005 | journal=SIAM Journal on Computing | issn=1095-7111 | volume=35 | issue=1 | page=188 | doi=10.1137/s0097539703436345| arxiv=quant-ph/0302112 | s2cid=15965140 }}</ref><ref>{{cite arXiv|eprint=quant-ph/0406151v1|author1=Oded Regev|title=A Subexponential Time Algorithm for the Dihedral Hidden Subgroup Problem with Polynomial Space|year=2004}}</ref> This definition allows larger running times than the first definition of sub-exponential time. An example of such a sub-exponential time algorithm is the best-known classical algorithm for integer factorization, the ], which runs in time about {{nowrap|<math>2^{\tilde{O}(n^{1/3})}</math>,}} where the length of the input is {{mvar|n}}. Another example was the ], which the best known algorithm from 1982 to 2016 solved in {{nowrap|<math>2^{O\left(\sqrt{n \log n}\right)}</math>.}} However, at ] 2016 a quasi-polynomial time algorithm was presented.<ref>{{cite book
| last1 = Grohe | first1 = Martin
| last2 = Neuen | first2 = Daniel
| editor1-last = Dabrowski | editor1-first = Konrad K.
| editor2-last = Gadouleau | editor2-first = Maximilien
| editor3-last = Georgiou | editor3-first = Nicholas
| editor4-last = Johnson | editor4-first = Matthew
| editor5-last = Mertzios | editor5-first = George B.
| editor6-last = Paulusma | editor6-first = Daniël
| arxiv = 2011.01366
| contribution = Recent advances on the graph isomorphism problem
| isbn = 978-1-009-01888-3
| mr = 4273431
| pages = 187–234
| publisher = Cambridge University Press
| series = London Mathematical Society Lecture Note Series
| title = Surveys in combinatorics 2021
| volume = 470
| year = 2021}}</ref>


Note that it makes a difference whether the algorithm is allowed to be sub-exponential in the size of the instance, the number of vertices, or the number of edges. In ], this difference is made explicit by considering pairs <math>(L,k)</math> of ]s and parameters ''k''. '''SUBEPT''' is the class of all parameterized problems that run in time sub-exponential in ''k'' and polynomial in the input size ''n'':<ref>{{Cite book It makes a difference whether the algorithm is allowed to be sub-exponential in the size of the instance, the number of vertices, or the number of edges. In ], this difference is made explicit by considering pairs <math>(L,k)</math> of ]s and parameters ''k''. '''SUBEPT''' is the class of all parameterized problems that run in time sub-exponential in ''k'' and polynomial in the input size ''n'':<ref>{{Cite book
| last=Flum | first=Jörg | last1=Flum | first1=Jörg
| last2=Grohe | first2=Martin | last2=Grohe | first2=Martin | author2-link = Martin Grohe
| title = Parameterized Complexity Theory | year = 2006 | publisher = Springer | title = Parameterized Complexity Theory | year = 2006 | publisher = Springer
| url = http://www.springer.com/east/home/generic/search/results?SGWID=5-40109-22-141358322-0 | url = https://www.springer.com/east/home/generic/search/results?SGWID=5-40109-22-141358322-0
| isbn = 978-3-540-29952-3 |ref=harv |accessdate=2010-03-05| page=417}}</ref> | isbn = 978-3-540-29952-3 | page=417}}</ref>


:<math>\text{SUBEPT}=\text{DTIME}\left(2^{o(k)} \cdot \text{poly}(n)\right).</math> :<math>\text{SUBEPT}=\text{DTIME}\left(2^{o(k)} \cdot \text{poly}(n)\right).</math>


More precisely, SUBEPT is the class of all parameterized problems <math>(L,k)</math> for which there is a ] <math>f : \mathbb N\to\mathbb N</math> with <math>f \in o(k)</math> and an algorithm that decides ''L'' in time <math>2^{f(k)} \cdot \text{poly}(n)</math>. More precisely, SUBEPT is the class of all parameterized problems <math>(L,k)</math> for which there is a ] <math>f : \N \to \N</math> with <math>f \in o(k)</math> and an algorithm that decides ''L'' in time <math>2^{f(k)} \cdot \text{poly}(n)</math>.


====Exponential time hypothesis==== ==== Exponential time hypothesis ====
{{Main|Exponential time hypothesis}} {{Main|Exponential time hypothesis}}


The '''exponential time hypothesis''' ('''ETH''') is that ], the satisfiability problem of Boolean formulas in ] with at most three literals per clause and with ''n'' variables, cannot be solved in time 2<sup>''o''(''n'')</sup>. More precisely, the hypothesis is that there is some absolute constant ''c''>0 such that 3SAT cannot be decided in time 2<sup>''cn''</sup> by any deterministic Turing machine. With ''m'' denoting the number of clauses, ETH is equivalent to the hypothesis that ''k''SAT cannot be solved in time 2<sup>''o''(''m'')</sup> for any integer ''k''&nbsp;&nbsp;3.<ref>{{Cite journal|first1=R.|last1=Impagliazzo|author1-link=Russell Impagliazzo|first2=R.|last2=Paturi|first3=F.|last3=Zane|title=Which problems have strongly exponential complexity?|journal=]|volume=63|issue=4|year=2001|pages=512–530|doi=10.1006/jcss.2001.1774}}</ref> The exponential time hypothesis implies ]. The '''exponential time hypothesis''' ('''ETH''') is that ], the satisfiability problem of Boolean formulas in ] with at most three literals per clause and with ''n'' variables, cannot be solved in time 2<sup>''o''(''n'')</sup>. More precisely, the hypothesis is that there is some absolute constant {{math|''c'' > 0}} such that 3SAT cannot be decided in time 2<sup>''cn''</sup> by any deterministic Turing machine. With ''m'' denoting the number of clauses, ETH is equivalent to the hypothesis that ''k''SAT cannot be solved in time 2<sup>''o''(''m'')</sup> for any integer {{math|''k'' 3}}.<ref>{{Cite journal|first1=R.|last1=Impagliazzo|author1-link=Russell Impagliazzo|first2=R.|last2=Paturi|first3=F.|last3=Zane|title=Which problems have strongly exponential complexity?|journal=]|volume=63|issue=4|year=2001|pages=512–530|doi=10.1006/jcss.2001.1774|doi-access=free}}</ref> The exponential time hypothesis implies ].


==Exponential time== == Exponential time ==
An algorithm is said to be '''exponential time''', if ''T''(''n'') is upper bounded by 2<sup>poly(''n'')</sup>, where poly(''n'') is some polynomial in ''n''. More formally, an algorithm is exponential time if ''T''(''n'') is bounded by O(2<sup>''n''<sup>''k''</sup></sup>) for some constant ''k''. Problems which admit exponential time algorithms on a deterministic Turing machine form the complexity class known as ''']'''. An algorithm is said to be '''exponential time''', if ''T''(''n'') is upper bounded by 2<sup>poly(''n'')</sup>, where poly(''n'') is some polynomial in ''n''. More formally, an algorithm is exponential time if ''T''(''n'') is bounded by ''O''(2<sup>''n''<sup>''k''</sup></sup>) for some constant ''k''. Problems which admit exponential time algorithms on a deterministic Turing machine form the complexity class known as ''']'''.
:<math>\text{EXP} = \bigcup_{c \in \mathbb{N}} \text{DTIME}\left(2^{n^c}\right)</math> :<math>\text{EXP} = \bigcup_{c \in \mathbb{R_+}} \text{DTIME}\left(2^{n^c}\right)</math>


Sometimes, exponential time is used to refer to algorithms that have ''T''(''n'') = 2<sup>O(''n'')</sup>, where the exponent is at most a linear function of ''n''. This gives rise to the complexity class ''']'''. Sometimes, exponential time is used to refer to algorithms that have ''T''(''n'') = 2<sup>''O''(''n'')</sup>, where the exponent is at most a linear function of ''n''. This gives rise to the complexity class ''']'''.
:<math>\text{E} = \bigcup_{c \in \mathbb{N}} \text{DTIME}\left(2^{cn}\right)</math> :<math>\text{E} = \bigcup_{c \in \mathbb{N}} \text{DTIME}\left(2^{cn}\right)</math>


==Double exponential time== == Factorial time ==

An algorithm is said to be '''factorial time''' if ''T(n)'' is upper bounded by the ] ''n!''. Factorial time is a subset of exponential time (EXP) because <math> n! \leq n^n = 2^{n \log n}= O \left(2^{n^{1 + \epsilon}} \right)</math> for all <math>\epsilon > 0</math>. However, it is not a subset of E.

An example of an algorithm that runs in factorial time is ], a notoriously inefficient sorting algorithm based on ]. Bogosort sorts a list of ''n'' items by repeatedly ] the list until it is found to be sorted. In the average case, each pass through the bogosort algorithm will examine one of the ''n''! orderings of the ''n'' items. If the items are distinct, only one such ordering is sorted. Bogosort shares patrimony with the ].

== Double exponential time ==
An algorithm is said to be ] time if ''T''(''n'') is upper bounded by 2<sup>2<sup>poly(''n'')</sup></sup>, where poly(''n'') is some polynomial in ''n''. Such algorithms belong to the complexity class ]. An algorithm is said to be ] time if ''T''(''n'') is upper bounded by 2<sup>2<sup>poly(''n'')</sup></sup>, where poly(''n'') is some polynomial in ''n''. Such algorithms belong to the complexity class ].
:<math>\mbox{2-EXPTIME} = \bigcup_{c \in \mathbb{N}} \mbox{DTIME}(2^{2^{n^c}})</math> :<math>\mbox{2-EXPTIME} = \bigcup_{c \in \N} \mbox{DTIME}\left( 2^{2^{n^c}}\right)</math>


Well-known double exponential time algorithms include: Well-known double exponential time algorithms include:
* Decision procedures for ] * Decision procedures for ]
* Computing a ] (in the worst case<ref>{{cite journal | last1 = Mayr | first1 = Ernst W. | author1-link = Ernst Mayr (computer scientist) | last2 = Meyer | first2 = Albert R. | author2-link = Albert R. Meyer | doi = 10.1016/0001-8708(82)90048-2 | issue = 3 | journal = ] | mr = 683204 | pages = 305–329 | title = The complexity of the word problems for commutative semigroups and polynomial ideals | volume = 46 | year = 1982| doi-access = free | hdl = 1721.1/149010 | hdl-access = free }}</ref>)
* Computing a ] (in the worst case)
* ] on ]s takes at least double exponential time,<ref>{{cite journal | last1 = Davenport | first1 = James H. | author1-link = James H. Davenport | last2 = Heintz | first2 = Joos|author2-link=Joos Ulrich Heintz | doi = 10.1016/S0747-7171(88)80004-X | issue = 1–2 | journal = ] | mr = 949111 | pages = 29–35 | title = Real quantifier elimination is doubly exponential | volume = 5 | year = 1988| doi-access = free }}</ref> and can be done in this time.<ref>{{cite conference | last = Collins | first = George E. | author-link = George E. Collins| editor-last = Brakhage | editor-first = H. | contribution = Quantifier elimination for real closed fields by cylindrical algebraic decomposition | doi = 10.1007/3-540-07407-4_17 | mr = 0403962 | pages = 134–183 | publisher = Springer | series = Lecture Notes in Computer Science | title = Automata Theory and Formal Languages: 2nd GI Conference, Kaiserslautern, May 20–23, 1975 | volume = 33 | year = 1975| doi-access = free | isbn = 978-3-540-07407-6 }}</ref>
* ] on ]s takes at least double exponential time (but is not even known to be computable in ])


==See also== == See also ==
* ] * ]
* ]


==References== == References ==
{{Reflist|colwidth=33em}} {{Reflist|colwidth=33em}}
{{Use dmy dates|date=September 2010}} {{Use dmy dates|date=September 2019}}


{{DEFAULTSORT:Time Complexity}}
] ]
] ]
] ]
]

Latest revision as of 11:17, 17 December 2024

Estimate of time taken for running an algorithm "Running time" redirects here. Not to be confused with Running Time (film).
Graphs of functions commonly used in the analysis of algorithms, showing the number of operations N as the result of input size n for each function

In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by the algorithm, supposing that each elementary operation takes a fixed amount of time to perform. Thus, the amount of time taken and the number of elementary operations performed by the algorithm are taken to be related by a constant factor.

Since an algorithm's running time may vary among different inputs of the same size, one commonly considers the worst-case time complexity, which is the maximum amount of time required for inputs of a given size. Less common, and usually specified explicitly, is the average-case complexity, which is the average of the time taken on inputs of a given size (this makes sense because there are only a finite number of possible inputs of a given size). In both cases, the time complexity is generally expressed as a function of the size of the input. Since this function is generally difficult to compute exactly, and the running time for small inputs is usually not consequential, one commonly focuses on the behavior of the complexity when the input size increases—that is, the asymptotic behavior of the complexity. Therefore, the time complexity is commonly expressed using big O notation, typically O ( n ) {\displaystyle O(n)} , O ( n log n ) {\displaystyle O(n\log n)} , O ( n α ) {\displaystyle O(n^{\alpha })} , O ( 2 n ) {\displaystyle O(2^{n})} , etc., where n is the size in units of bits needed to represent the input.

Algorithmic complexities are classified according to the type of function appearing in the big O notation. For example, an algorithm with time complexity O ( n ) {\displaystyle O(n)} is a linear time algorithm and an algorithm with time complexity O ( n α ) {\displaystyle O(n^{\alpha })} for some constant α > 0 {\displaystyle \alpha >0} is a polynomial time algorithm.

Table of common time complexities

Further information: Computational complexity of mathematical operations

The following table summarizes some classes of commonly encountered time complexities. In the table, poly(x) = x, i.e., polynomial in x.

Name Complexity class Time complexity (O(n)) Examples of running times Example algorithms
constant time O ( 1 ) {\displaystyle O(1)} 10 Finding the median value in a sorted array of numbers. Calculating (−1).
inverse Ackermann time O ( α ( n ) ) {\displaystyle O{\bigl (}\alpha (n){\bigr )}} Amortized time per operation using a disjoint set
iterated logarithmic time O ( log n ) {\displaystyle O(\log ^{*}n)} Distributed coloring of cycles
log-logarithmic O ( log log n ) {\displaystyle O(\log \log n)} Amortized time per operation using a bounded priority queue
logarithmic time DLOGTIME O ( log n ) {\displaystyle O(\log n)} log n {\displaystyle \log n} , log ( n 2 ) {\displaystyle \log(n^{2})} Binary search
polylogarithmic time poly ( log n ) {\displaystyle {\text{poly}}(\log n)} ( log n ) 2 {\displaystyle (\log n)^{2}}
fractional power O ( n c ) {\displaystyle O(n^{c})} where 0 < c < 1 {\displaystyle 0<c<1} n 1 2 {\displaystyle n^{\frac {1}{2}}} , n 2 3 {\displaystyle n^{\frac {2}{3}}} Range searching in a k-d tree
linear time O ( n ) {\displaystyle O(n)} n, 2 n + 5 {\displaystyle 2n+5} Finding the smallest or largest item in an unsorted array. Kadane's algorithm. Linear search.
"n log-star n" time O ( n log n ) {\displaystyle O(n\log ^{*}n)} Seidel's polygon triangulation algorithm.
linearithmic time O ( n log n ) {\displaystyle O(n\log n)} n log n {\displaystyle n\log n} , log n ! {\displaystyle \log n!} Fastest possible comparison sort. Fast Fourier transform.
quasilinear time n poly ( log n ) {\displaystyle n{\text{poly}}(\log n)} n log 2 n {\displaystyle n\log ^{2}n} Multipoint polynomial evaluation
quadratic time O ( n 2 ) {\displaystyle O(n^{2})} n 2 {\displaystyle n^{2}} Bubble sort. Insertion sort. Direct convolution
cubic time O ( n 3 ) {\displaystyle O(n^{3})} n 3 {\displaystyle n^{3}} Naive multiplication of two n × n {\displaystyle n\times n} matrices. Calculating partial correlation.
polynomial time P 2 O ( log n ) = poly ( n ) {\displaystyle 2^{O(\log n)}={\text{poly}}(n)} n 2 + n {\displaystyle n^{2}+n} , n 10 {\displaystyle n^{10}} Karmarkar's algorithm for linear programming. AKS primality test
quasi-polynomial time QP 2 poly ( log n ) {\displaystyle 2^{{\text{poly}}(\log n)}} n log log n {\displaystyle n^{\log \log n}} , n log n {\displaystyle n^{\log n}} Best-known O(logn)-approximation algorithm for the directed Steiner tree problem, best known parity game solver, best known graph isomorphism algorithm
sub-exponential time
(first definition)
SUBEXP O ( 2 n ϵ ) {\displaystyle O(2^{n^{\epsilon }})} for all 0 < ϵ < 1 {\displaystyle 0<\epsilon <1} Contains BPP unless EXPTIME (see below) equals MA.
sub-exponential time
(second definition)
2 o ( n ) {\displaystyle 2^{o(n)}} 2 n 3 {\displaystyle 2^{\sqrt{n}}} Best classical algorithm for integer factorization

formerly-best algorithm for graph isomorphism

exponential time
(with linear exponent)
E 2 O ( n ) {\displaystyle 2^{O(n)}} 1.1 n {\displaystyle 1.1^{n}} , 10 n {\displaystyle 10^{n}} Solving the traveling salesman problem using dynamic programming
factorial time O ( n ) ! = 2 O ( n log n ) {\displaystyle O(n)!=2^{O(n\log n)}} n ! , n n , 2 n log n {\displaystyle n!,n^{n},2^{n\log n}} Solving the traveling salesman problem via brute-force search
exponential time EXPTIME 2 poly ( n ) {\displaystyle 2^{{\text{poly}}(n)}} 2 n {\displaystyle 2^{n}} , 2 n 2 {\displaystyle 2^{n^{2}}} Solving matrix chain multiplication via brute-force search
double exponential time 2-EXPTIME 2 2 poly ( n ) {\displaystyle 2^{2^{{\text{poly}}(n)}}} 2 2 n {\displaystyle 2^{2^{n}}} Deciding the truth of a given statement in Presburger arithmetic

Constant time

"Constant time" redirects here. For programming technique to avoid a timing attack, see Timing attack § Avoidance.

An algorithm is said to be constant time (also written as O ( 1 ) {\textstyle O(1)} time) if the value of T ( n ) {\textstyle T(n)} (the complexity of the algorithm) is bounded by a value that does not depend on the size of the input. For example, accessing any single element in an array takes constant time as only one operation has to be performed to locate it. In a similar manner, finding the minimal value in an array sorted in ascending order; it is the first element. However, finding the minimal value in an unordered array is not a constant time operation as scanning over each element in the array is needed in order to determine the minimal value. Hence it is a linear time operation, taking O ( n ) {\textstyle O(n)} time. If the number of elements is known in advance and does not change, however, such an algorithm can still be said to run in constant time.

Despite the name "constant time", the running time does not have to be independent of the problem size, but an upper bound for the running time has to be independent of the problem size. For example, the task "exchange the values of a and b if necessary so that a b {\textstyle a\leq b} " is called constant time even though the time may depend on whether or not it is already true that a b {\textstyle a\leq b} . However, there is some constant t such that the time required is always at most t.

Logarithmic time

Further information: Logarithmic growth

An algorithm is said to take logarithmic time when T ( n ) = O ( log n ) {\displaystyle T(n)=O(\log n)} . Since log a n {\displaystyle \log _{a}n} and log b n {\displaystyle \log _{b}n} are related by a constant multiplier, and such a multiplier is irrelevant to big O classification, the standard usage for logarithmic-time algorithms is O ( log n ) {\displaystyle O(\log n)} regardless of the base of the logarithm appearing in the expression of T.

Algorithms taking logarithmic time are commonly found in operations on binary trees or when using binary search.

An O ( log n ) {\displaystyle O(\log n)} algorithm is considered highly efficient, as the ratio of the number of operations to the size of the input decreases and tends to zero when n increases. An algorithm that must access all elements of its input cannot take logarithmic time, as the time taken for reading an input of size n is of the order of n.

An example of logarithmic time is given by dictionary search. Consider a dictionary D which contains n entries, sorted in alphabetical order. We suppose that, for 1 k n {\displaystyle 1\leq k\leq n} , one may access the kth entry of the dictionary in a constant time. Let D ( k ) {\displaystyle D(k)} denote this kth entry. Under these hypotheses, the test to see if a word w is in the dictionary may be done in logarithmic time: consider D ( n 2 ) {\displaystyle D\left(\left\lfloor {\frac {n}{2}}\right\rfloor \right)} , where {\displaystyle \lfloor \;\rfloor } denotes the floor function. If w = D ( n 2 ) {\displaystyle w=D\left(\left\lfloor {\frac {n}{2}}\right\rfloor \right)} --that is to say, the word w is exactly in the middle of the dictionary--then we are done. Else, if w < D ( n 2 ) {\displaystyle w<D\left(\left\lfloor {\frac {n}{2}}\right\rfloor \right)} --i.e., if the word w comes earlier in alphabetical order than the middle word of the whole dictionary--we continue the search in the same way in the left (i.e. earlier) half of the dictionary, and then again repeatedly until the correct word is found. Otherwise, if it comes after the middle word, continue similarly with the right half of the dictionary. This algorithm is similar to the method often used to find an entry in a paper dictionary. As a result, the search space within the dictionary decreases as the algorithm gets closer to the target word.

Polylogarithmic time

An algorithm is said to run in polylogarithmic time if its time T ( n ) {\displaystyle T(n)} is O ( ( log n ) k ) {\displaystyle O{\bigl (}(\log n)^{k}{\bigr )}} for some constant k. Another way to write this is O ( log k n ) {\displaystyle O(\log ^{k}n)} .

For example, matrix chain ordering can be solved in polylogarithmic time on a parallel random-access machine, and a graph can be determined to be planar in a fully dynamic way in O ( log 3 n ) {\displaystyle O(\log ^{3}n)} time per insert/delete operation.

Sub-linear time

An algorithm is said to run in sub-linear time (often spelled sublinear time) if T ( n ) = o ( n ) {\displaystyle T(n)=o(n)} . In particular this includes algorithms with the time complexities defined above.

The specific term sublinear time algorithm commonly refers to randomized algorithms that sample a small fraction of their inputs and process them efficiently to approximately infer properties of the entire instance. This type of sublinear time algorithm is closely related to property testing and statistics.

Other settings where algorithms can run in sublinear time include:

  • Parallel algorithms that have linear or greater total work (allowing them to read the entire input), but sub-linear depth.
  • Algorithms that have guaranteed assumptions on the input structure. An important example are operations on data structures, e.g. binary search in a sorted array.
  • Algorithms that search for local structure in the input, for example finding a local minimum in a 1-D array (can be solved in  O ( log ( n ) ) {\displaystyle O(\log(n))} time using a variant of binary search).  A closely related notion is that of Local Computation Algorithms (LCA) where the algorithm receives a large input and queries to local information about some valid large output.

Linear time

An algorithm is said to take linear time, or O ( n ) {\displaystyle O(n)} time, if its time complexity is O ( n ) {\displaystyle O(n)} . Informally, this means that the running time increases at most linearly with the size of the input. More precisely, this means that there is a constant c such that the running time is at most c n {\displaystyle cn} for every input of size n. For example, a procedure that adds up all elements of a list requires time proportional to the length of the list, if the adding time is constant, or, at least, bounded by a constant.

Linear time is the best possible time complexity in situations where the algorithm has to sequentially read its entire input. Therefore, much research has been invested into discovering algorithms exhibiting linear time or, at least, nearly linear time. This research includes both software and hardware methods. There are several hardware technologies which exploit parallelism to provide this. An example is content-addressable memory. This concept of linear time is used in string matching algorithms such as the Boyer–Moore string-search algorithm and Ukkonen's algorithm.

Quasilinear time

An algorithm is said to run in quasilinear time (also referred to as log-linear time) if T ( n ) = O ( n log k n ) {\displaystyle T(n)=O(n\log ^{k}n)} for some positive constant k; linearithmic time is the case k = 1 {\displaystyle k=1} . Using soft O notation these algorithms are O ~ ( n ) {\displaystyle {\tilde {O}}(n)} . Quasilinear time algorithms are also O ( n 1 + ε ) {\displaystyle O(n^{1+\varepsilon })} for every constant ε > 0 {\displaystyle \varepsilon >0} and thus run faster than any polynomial time algorithm whose time bound includes a term n c {\displaystyle n^{c}} for any c > 1 {\displaystyle c>1} .

Algorithms which run in quasilinear time include:

  • In-place merge sort, O ( n log 2 n ) {\displaystyle O(n\log ^{2}n)}
  • Quicksort, O ( n log n ) {\displaystyle O(n\log n)} , in its randomized version, has a running time that is O ( n log n ) {\displaystyle O(n\log n)} in expectation on the worst-case input. Its non-randomized version has an O ( n log n ) {\displaystyle O(n\log n)} running time only when considering average case complexity.
  • Heapsort, O ( n log n ) {\displaystyle O(n\log n)} , merge sort, introsort, binary tree sort, smoothsort, patience sorting, etc. in the worst case
  • Fast Fourier transforms, O ( n log n ) {\displaystyle O(n\log n)}
  • Monge array calculation, O ( n log n ) {\displaystyle O(n\log n)}

In many cases, the O ( n log n ) {\displaystyle O(n\log n)} running time is simply the result of performing a Θ ( log n ) {\displaystyle \Theta (\log n)} operation n times (for the notation, see Big O notation § Family of Bachmann–Landau notations). For example, binary tree sort creates a binary tree by inserting each element of the n-sized array one by one. Since the insert operation on a self-balancing binary search tree takes O ( log n ) {\displaystyle O(\log n)} time, the entire algorithm takes O ( n log n ) {\displaystyle O(n\log n)} time.

Comparison sorts require at least Ω ( n log n ) {\displaystyle \Omega (n\log n)} comparisons in the worst case because log ( n ! ) = Θ ( n log n ) {\displaystyle \log(n!)=\Theta (n\log n)} , by Stirling's approximation. They also frequently arise from the recurrence relation T ( n ) = 2 T ( n 2 ) + O ( n ) {\textstyle T(n)=2T\left({\frac {n}{2}}\right)+O(n)} .

Sub-quadratic time

An algorithm is said to be subquadratic time if T ( n ) = o ( n 2 ) {\displaystyle T(n)=o(n^{2})} .

For example, simple, comparison-based sorting algorithms are quadratic (e.g. insertion sort), but more advanced algorithms can be found that are subquadratic (e.g. shell sort). No general-purpose sorts run in linear time, but the change from quadratic to sub-quadratic is of great practical importance.

Polynomial time

Main article: P (complexity)

An algorithm is said to be of polynomial time if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm, that is, T(n) = O(n) for some positive constant k. Problems for which a deterministic polynomial-time algorithm exists belong to the complexity class P, which is central in the field of computational complexity theory. Cobham's thesis states that polynomial time is a synonym for "tractable", "feasible", "efficient", or "fast".

Some examples of polynomial-time algorithms:

  • The selection sort sorting algorithm on n integers performs A n 2 {\displaystyle An^{2}} operations for some constant A. Thus it runs in time O ( n 2 ) {\displaystyle O(n^{2})} and is a polynomial-time algorithm.
  • All the basic arithmetic operations (addition, subtraction, multiplication, division, and comparison) can be done in polynomial time.
  • Maximum matchings in graphs can be found in polynomial time. In some contexts, especially in optimization, one differentiates between strongly polynomial time and weakly polynomial time algorithms.

These two concepts are only relevant if the inputs to the algorithms consist of integers.

Complexity classes

The concept of polynomial time leads to several complexity classes in computational complexity theory. Some important classes defined using polynomial time are the following.

P is the smallest time-complexity class on a deterministic machine which is robust in terms of machine model changes. (For example, a change from a single-tape Turing machine to a multi-tape machine can lead to a quadratic speedup, but any algorithm that runs in polynomial time under one model also does so on the other.) Any given abstract machine will have a complexity class corresponding to the problems which can be solved in polynomial time on that machine.

Superpolynomial time

An algorithm is defined to take superpolynomial time if T(n) is not bounded above by any polynomial. Using little omega notation, it is ω(n) time for all constants c, where n is the input parameter, typically the number of bits in the input.

For example, an algorithm that runs for 2 steps on an input of size n requires superpolynomial time (more specifically, exponential time).

An algorithm that uses exponential resources is clearly superpolynomial, but some algorithms are only very weakly superpolynomial. For example, the Adleman–Pomerance–Rumely primality test runs for n time on n-bit inputs; this grows faster than any polynomial for large enough n, but the input size must become impractically large before it cannot be dominated by a polynomial with small degree.

An algorithm that requires superpolynomial time lies outside the complexity class P. Cobham's thesis posits that these algorithms are impractical, and in many cases they are. Since the P versus NP problem is unresolved, it is unknown whether NP-complete problems require superpolynomial time.

Quasi-polynomial time

Main article: Quasi-polynomial time

Quasi-polynomial time algorithms are algorithms whose running time exhibits quasi-polynomial growth, a type of behavior that may be slower than polynomial time but yet is significantly faster than exponential time. The worst case running time of a quasi-polynomial time algorithm is 2 O ( log c n ) {\displaystyle 2^{O(\log ^{c}n)}} for some fixed c > 0 {\displaystyle c>0} . When c = 1 {\displaystyle c=1} this gives polynomial time, and for c < 1 {\displaystyle c<1} it gives sub-linear time.

There are some problems for which we know quasi-polynomial time algorithms, but no polynomial time algorithm is known. Such problems arise in approximation algorithms; a famous example is the directed Steiner tree problem, for which there is a quasi-polynomial time approximation algorithm achieving an approximation factor of O ( log 3 n ) {\displaystyle O(\log ^{3}n)} (n being the number of vertices), but showing the existence of such a polynomial time algorithm is an open problem.

Other computational problems with quasi-polynomial time solutions but no known polynomial time solution include the planted clique problem in which the goal is to find a large clique in the union of a clique and a random graph. Although quasi-polynomially solvable, it has been conjectured that the planted clique problem has no polynomial time solution; this planted clique conjecture has been used as a computational hardness assumption to prove the difficulty of several other problems in computational game theory, property testing, and machine learning.

The complexity class QP consists of all problems that have quasi-polynomial time algorithms. It can be defined in terms of DTIME as follows.

QP = c N DTIME ( 2 log c n ) {\displaystyle {\mbox{QP}}=\bigcup _{c\in \mathbb {N} }{\mbox{DTIME}}\left(2^{\log ^{c}n}\right)}

Relation to NP-complete problems

In complexity theory, the unsolved P versus NP problem asks if all problems in NP have polynomial-time algorithms. All the best-known algorithms for NP-complete problems like 3SAT etc. take exponential time. Indeed, it is conjectured for many natural NP-complete problems that they do not have sub-exponential time algorithms. Here "sub-exponential time" is taken to mean the second definition presented below. (On the other hand, many graph problems represented in the natural way by adjacency matrices are solvable in subexponential time simply because the size of the input is the square of the number of vertices.) This conjecture (for the k-SAT problem) is known as the exponential time hypothesis. Since it is conjectured that NP-complete problems do not have quasi-polynomial time algorithms, some inapproximability results in the field of approximation algorithms make the assumption that NP-complete problems do not have quasi-polynomial time algorithms. For example, see the known inapproximability results for the set cover problem.

Sub-exponential time

The term sub-exponential time is used to express that the running time of some algorithm may grow faster than any polynomial but is still significantly smaller than an exponential. In this sense, problems that have sub-exponential time algorithms are somewhat more tractable than those that only have exponential algorithms. The precise definition of "sub-exponential" is not generally agreed upon, however the two most widely used are below.

First definition

A problem is said to be sub-exponential time solvable if it can be solved in running times whose logarithms grow smaller than any given polynomial. More precisely, a problem is in sub-exponential time if for every ε > 0 there exists an algorithm which solves the problem in time O(2). The set of all such problems is the complexity class SUBEXP which can be defined in terms of DTIME as follows.

SUBEXP = ε > 0 DTIME ( 2 n ε ) {\displaystyle {\text{SUBEXP}}=\bigcap _{\varepsilon >0}{\text{DTIME}}\left(2^{n^{\varepsilon }}\right)}

This notion of sub-exponential is non-uniform in terms of ε in the sense that ε is not part of the input and each ε may have its own algorithm for the problem.

Second definition

Some authors define sub-exponential time as running times in 2 o ( n ) {\displaystyle 2^{o(n)}} . This definition allows larger running times than the first definition of sub-exponential time. An example of such a sub-exponential time algorithm is the best-known classical algorithm for integer factorization, the general number field sieve, which runs in time about 2 O ~ ( n 1 / 3 ) {\displaystyle 2^{{\tilde {O}}(n^{1/3})}} , where the length of the input is n. Another example was the graph isomorphism problem, which the best known algorithm from 1982 to 2016 solved in 2 O ( n log n ) {\displaystyle 2^{O\left({\sqrt {n\log n}}\right)}} . However, at STOC 2016 a quasi-polynomial time algorithm was presented.

It makes a difference whether the algorithm is allowed to be sub-exponential in the size of the instance, the number of vertices, or the number of edges. In parameterized complexity, this difference is made explicit by considering pairs ( L , k ) {\displaystyle (L,k)} of decision problems and parameters k. SUBEPT is the class of all parameterized problems that run in time sub-exponential in k and polynomial in the input size n:

SUBEPT = DTIME ( 2 o ( k ) poly ( n ) ) . {\displaystyle {\text{SUBEPT}}={\text{DTIME}}\left(2^{o(k)}\cdot {\text{poly}}(n)\right).}

More precisely, SUBEPT is the class of all parameterized problems ( L , k ) {\displaystyle (L,k)} for which there is a computable function f : N N {\displaystyle f:\mathbb {N} \to \mathbb {N} } with f o ( k ) {\displaystyle f\in o(k)} and an algorithm that decides L in time 2 f ( k ) poly ( n ) {\displaystyle 2^{f(k)}\cdot {\text{poly}}(n)} .

Exponential time hypothesis

Main article: Exponential time hypothesis

The exponential time hypothesis (ETH) is that 3SAT, the satisfiability problem of Boolean formulas in conjunctive normal form with at most three literals per clause and with n variables, cannot be solved in time 2. More precisely, the hypothesis is that there is some absolute constant c > 0 such that 3SAT cannot be decided in time 2 by any deterministic Turing machine. With m denoting the number of clauses, ETH is equivalent to the hypothesis that kSAT cannot be solved in time 2 for any integer k ≥ 3. The exponential time hypothesis implies P ≠ NP.

Exponential time

An algorithm is said to be exponential time, if T(n) is upper bounded by 2, where poly(n) is some polynomial in n. More formally, an algorithm is exponential time if T(n) is bounded by O(2) for some constant k. Problems which admit exponential time algorithms on a deterministic Turing machine form the complexity class known as EXP.

EXP = c R + DTIME ( 2 n c ) {\displaystyle {\text{EXP}}=\bigcup _{c\in \mathbb {R_{+}} }{\text{DTIME}}\left(2^{n^{c}}\right)}

Sometimes, exponential time is used to refer to algorithms that have T(n) = 2, where the exponent is at most a linear function of n. This gives rise to the complexity class E.

E = c N DTIME ( 2 c n ) {\displaystyle {\text{E}}=\bigcup _{c\in \mathbb {N} }{\text{DTIME}}\left(2^{cn}\right)}

Factorial time

An algorithm is said to be factorial time if T(n) is upper bounded by the factorial function n!. Factorial time is a subset of exponential time (EXP) because n ! n n = 2 n log n = O ( 2 n 1 + ϵ ) {\displaystyle n!\leq n^{n}=2^{n\log n}=O\left(2^{n^{1+\epsilon }}\right)} for all ϵ > 0 {\displaystyle \epsilon >0} . However, it is not a subset of E.

An example of an algorithm that runs in factorial time is bogosort, a notoriously inefficient sorting algorithm based on trial and error. Bogosort sorts a list of n items by repeatedly shuffling the list until it is found to be sorted. In the average case, each pass through the bogosort algorithm will examine one of the n! orderings of the n items. If the items are distinct, only one such ordering is sorted. Bogosort shares patrimony with the infinite monkey theorem.

Double exponential time

An algorithm is said to be double exponential time if T(n) is upper bounded by 2, where poly(n) is some polynomial in n. Such algorithms belong to the complexity class 2-EXPTIME.

2-EXPTIME = c N DTIME ( 2 2 n c ) {\displaystyle {\mbox{2-EXPTIME}}=\bigcup _{c\in \mathbb {N} }{\mbox{DTIME}}\left(2^{2^{n^{c}}}\right)}

Well-known double exponential time algorithms include:

See also

References

  1. ^ Sipser, Michael (2006). Introduction to the Theory of Computation. Course Technology Inc. ISBN 0-619-21764-2.
  2. Mehlhorn, Kurt; Naher, Stefan (1990). "Bounded ordered dictionaries in O(log log N) time and O(n) space". Information Processing Letters. 35 (4): 183–189. doi:10.1016/0020-0190(90)90022-P.
  3. Tao, Terence (2010). "1.11 The AKS primality test". An epsilon of room, II: Pages from year three of a mathematical blog. Graduate Studies in Mathematics. Vol. 117. Providence, RI: American Mathematical Society. pp. 82–86. doi:10.1090/gsm/117. ISBN 978-0-8218-5280-4. MR 2780010.
  4. Lenstra, H. W. Jr.; Pomerance, Carl (2019). "Primality testing with Gaussian periods" (PDF). Journal of the European Mathematical Society. 21 (4): 1229–1269. doi:10.4171/JEMS/861. hdl:21.11116/0000-0005-717D-0. MR 3941463. S2CID 127807021.
  5. Calude, Cristian S. and Jain, Sanjay and Khoussainov, Bakhadyr and Li, Wei and Stephan, Frank (2017). "Deciding parity games in quasipolynomial time". Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing. Association for Computing Machinery. pp. 252–263. doi:10.1145/3055399.3055409. hdl:2292/31757. ISBN 9781450345286. S2CID 30338402.{{cite book}}: CS1 maint: multiple names: authors list (link)
  6. ^ Babai, László; Fortnow, Lance; Nisan, N.; Wigderson, Avi (1993). "BPP has subexponential time simulations unless EXPTIME has publishable proofs". Computational Complexity. 3 (4). Berlin, New York: Springer-Verlag: 307–318. doi:10.1007/BF01275486. S2CID 14802332.
  7. Bradford, Phillip G.; Rawlins, Gregory J. E.; Shannon, Gregory E. (1998). "Efficient matrix chain ordering in polylog time". SIAM Journal on Computing. 27 (2): 466–490. doi:10.1137/S0097539794270698. MR 1616556.
  8. Holm, Jacob; Rotenberg, Eva (2020). "Fully-dynamic planarity testing in polylogarithmic time". In Makarychev, Konstantin; Makarychev, Yury; Tulsiani, Madhur; Kamath, Gautam; Chuzhoy, Julia (eds.). Proceedings of the 52nd Annual ACM SIGACT Symposium on Theory of Computing, STOC 2020, Chicago, IL, USA, June 22-26, 2020. Association for Computing Machinery. pp. 167–180. arXiv:1911.03449. doi:10.1145/3357713.3384249. ISBN 978-1-4503-6979-4.
  9. Kumar, Ravi; Rubinfeld, Ronitt (2003). "Sublinear time algorithms" (PDF). SIGACT News. 34 (4): 57–67. doi:10.1145/954092.954103. S2CID 65359.
  10. Rubinfeld, Ronitt (2019). "Local Computation Algorithms". Proceedings of the 2019 ACM Symposium on Principles of Distributed Computing (PODC). p. 3. doi:10.1145/3293611.3331587. ISBN 978-1-4503-6217-7.
  11. Naik, Ashish V.; Regan, Kenneth W.; Sivakumar, D. (1995). "On quasilinear-time complexity theory" (PDF). Theoretical Computer Science. 148 (2): 325–349. doi:10.1016/0304-3975(95)00031-Q. MR 1355592.
  12. Sedgewick, Robert; Wayne, Kevin (2011). Algorithms (4th ed.). Pearson Education. p. 186.
  13. Papadimitriou, Christos H. (1994). Computational complexity. Reading, Mass.: Addison-Wesley. ISBN 0-201-53082-1.
  14. Cobham, Alan (1965). "The intrinsic computational difficulty of functions". Proc. Logic, Methodology, and Philosophy of Science II. North Holland.
  15. Braverman, Mark; Kun-Ko, Young; Rubinstein, Aviad; Weinstein, Omri (2017). "ETH hardness for densest-k-subgraph with perfect completeness". In Klein, Philip N. (ed.). Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19. Society for Industrial and Applied Mathematics. pp. 1326–1341. arXiv:1504.08352. doi:10.1137/1.9781611974782.86. ISBN 978-1-61197-478-2. MR 3627815.
  16. Complexity Zoo: Class QP: Quasipolynomial-Time
  17. ^ Impagliazzo, Russell; Paturi, Ramamohan (2001). "On the complexity of k-SAT" (PDF). Journal of Computer and System Sciences. 62 (2): 367–375. doi:10.1006/jcss.2000.1727. MR 1820597.
  18. Aaronson, Scott (5 April 2009). "A not-quite-exponential dilemma". Shtetl-Optimized. Retrieved 2 December 2009.
  19. Complexity Zoo: Class SUBEXP: Deterministic Subexponential-Time
  20. Moser, P. (2003). "Baire's Categories on Small Complexity Classes". In Andrzej Lingas; Bengt J. Nilsson (eds.). Fundamentals of Computation Theory: 14th International Symposium, FCT 2003, Malmö, Sweden, August 12-15, 2003, Proceedings. Lecture Notes in Computer Science. Vol. 2751. Berlin, New York: Springer-Verlag. pp. 333–342. doi:10.1007/978-3-540-45077-1_31. ISBN 978-3-540-40543-6. ISSN 0302-9743.
  21. Miltersen, P.B. (2001). "Derandomizing Complexity Classes". Handbook of Randomized Computing. Combinatorial Optimization. 9. Kluwer Academic Pub: 843. doi:10.1007/978-1-4615-0013-1_19 (inactive 1 November 2024). ISBN 978-1-4613-4886-3.{{cite journal}}: CS1 maint: DOI inactive as of November 2024 (link)
  22. Kuperberg, Greg (2005). "A Subexponential-Time Quantum Algorithm for the Dihedral Hidden Subgroup Problem". SIAM Journal on Computing. 35 (1). Philadelphia: 188. arXiv:quant-ph/0302112. doi:10.1137/s0097539703436345. ISSN 1095-7111. S2CID 15965140.
  23. Oded Regev (2004). "A Subexponential Time Algorithm for the Dihedral Hidden Subgroup Problem with Polynomial Space". arXiv:quant-ph/0406151v1.
  24. Grohe, Martin; Neuen, Daniel (2021). "Recent advances on the graph isomorphism problem". In Dabrowski, Konrad K.; Gadouleau, Maximilien; Georgiou, Nicholas; Johnson, Matthew; Mertzios, George B.; Paulusma, Daniël (eds.). Surveys in combinatorics 2021. London Mathematical Society Lecture Note Series. Vol. 470. Cambridge University Press. pp. 187–234. arXiv:2011.01366. ISBN 978-1-009-01888-3. MR 4273431.
  25. Flum, Jörg; Grohe, Martin (2006). Parameterized Complexity Theory. Springer. p. 417. ISBN 978-3-540-29952-3.
  26. Impagliazzo, R.; Paturi, R.; Zane, F. (2001). "Which problems have strongly exponential complexity?". Journal of Computer and System Sciences. 63 (4): 512–530. doi:10.1006/jcss.2001.1774.
  27. Mayr, Ernst W.; Meyer, Albert R. (1982). "The complexity of the word problems for commutative semigroups and polynomial ideals". Advances in Mathematics. 46 (3): 305–329. doi:10.1016/0001-8708(82)90048-2. hdl:1721.1/149010. MR 0683204.
  28. Davenport, James H.; Heintz, Joos (1988). "Real quantifier elimination is doubly exponential". Journal of Symbolic Computation. 5 (1–2): 29–35. doi:10.1016/S0747-7171(88)80004-X. MR 0949111.
  29. Collins, George E. (1975). "Quantifier elimination for real closed fields by cylindrical algebraic decomposition". In Brakhage, H. (ed.). Automata Theory and Formal Languages: 2nd GI Conference, Kaiserslautern, May 20–23, 1975. Lecture Notes in Computer Science. Vol. 33. Springer. pp. 134–183. doi:10.1007/3-540-07407-4_17. ISBN 978-3-540-07407-6. MR 0403962.

Categories: