Incomputational complexity theory, theaverage-case complexity of analgorithm is the amount of somecomputational resource (typically time) used by the algorithm, averaged over all possible inputs. It is frequently contrasted withworst-case complexity which considers the maximal complexity of the algorithm over all possible inputs.
There are three primary motivations for studying average-case complexity.[1] First, although some problems may be intractable in the worst-case, the inputs which elicit this behavior may rarely occur in practice, so the average-case complexity may be a more accurate measure of an algorithm's performance. Second, average-case complexity analysis provides tools and techniques to generate hard instances of problems which can be utilized in areas such ascryptography andderandomization. Third, average-case complexity allows discriminating the most efficient algorithm in practice among algorithms of equivalent best case complexity (for instanceQuicksort).
Average-case analysis requires a notion of an "average" input to an algorithm, which leads to the problem of devising aprobability distribution over inputs. Alternatively, arandomized algorithm can be used. The analysis of such algorithms leads to the related notion of anexpected complexity.[2]: 28
The average-case performance of algorithms has been studied since modern notions of computational efficiency were developed in the 1950s. Much of this initial work focused on problems for which worst-case polynomial time algorithms were already known.[3] In 1973,Donald Knuth[4] published Volume 3 of theArt of Computer Programming which extensively surveys average-case performance of algorithms for problems solvable in worst-case polynomial time, such as sorting and median-finding.
An efficient algorithm forNP-complete problems is generally characterized as one which runs in polynomial time for all inputs; this is equivalent to requiring efficient worst-case complexity. However, an algorithm which is inefficient on a "small" number of inputs may still be efficient for "most" inputs that occur in practice. Thus, it is desirable to study the properties of these algorithms where the average-case complexity may differ from the worst-case complexity and find methods to relate the two.
The fundamental notions of average-case complexity were developed byLeonid Levin in 1986 when he published a one-page paper[5] defining average-case complexity and completeness while giving an example of a complete problem fordistNP, the average-case analogue ofNP.
The first task is to precisely define what is meant by an algorithm which is efficient "on average". An initial attempt might define an efficient average-case algorithm as one which runs in expected polynomial time over all possible inputs. Such a definition has various shortcomings; in particular, it is not robust to changes in the computational model. For example, suppose algorithmA runs in timetA(x) on inputx and algorithmB runs in timetA(x)2 on inputx; that is,B is quadratically slower thanA. Intuitively, any definition of average-case efficiency should capture the idea thatA is efficient-on-average if and only ifB is efficient on-average. Suppose, however, that the inputs are drawn randomly from the uniform distribution of strings with lengthn, and thatA runs in timen2 on all inputs except the string1n for whichA takes time2n. Then it can be easily checked that the expected running time ofA is polynomial but the expected running time ofB is exponential.[3]
To create a more robust definition of average-case efficiency, it makes sense to allow an algorithmA to run longer than polynomial time on some inputs but the fraction of inputs on whichA requires larger and larger running time becomes smaller and smaller. This intuition is captured in the following formula for average polynomial running time, which balances the polynomial trade-off between running time and fraction of inputs:
for everyn,t > 0 and polynomialp, wheretA(x) denotes the running time of algorithmA on inputx, andε is a positive constant value.[6] Alternatively, this can be written as
for some constantsC andε, wheren = |x|.[7] In other words, an algorithmA has good average-case complexity if, after running fortA(n) steps,A can solve all but anc/(tA(n))ε fraction of inputs of lengthn, for someε,c > 0.[3]
The next step is to define the "average" input to a particular problem. This is achieved by associating the inputs of each problem with a particular probability distribution. That is, an "average-case" problem consists of a languageL and an associated probability distributionD which forms the pair(L,D).[7] The two most common classes of distributions which are allowed are:
These two formulations, while similar, are not equivalent. If a distribution isP-computable it is alsoP-samplable, but the converse is not true ifP ≠P#P.[7]
A distributional problem(L,D) is in the complexity classAvgP if there is an efficient average-case algorithm forL, as defined above. The classAvgP is occasionally calleddistP in the literature.[7]
A distributional problem(L,D) is in the complexity classdistNP ifL is inNP andD isP-computable. WhenL is inNP andD isP-samplable,(L,D) belongs tosampNP.[7]
Together,AvgP anddistNP define the average-case analogues ofP andNP, respectively.[7]
Let(L,D) and(L′,D′) be two distributional problems.(L,D) average-case reduces to(L′,D′) (written(L,D) ≤AvgP (L′,D′)) if there is a functionf that for everyn, on inputx can be computed in time polynomial inn and
The domination condition enforces the notion that if problem(L,D) is hard on average, then(L′,D′) is also hard on average. Intuitively, a reduction should provide a way to solve an instancex of problemL by computingf(x) and feeding the output to the algorithm which solvesL'. Without the domination condition, this may not be possible since the algorithm which solvesL in polynomial time on average may take super-polynomial time on a small number of inputs butf may map these inputs into a much larger set ofD' so that algorithmA' no longer runs in polynomial time on average. The domination condition only allows such strings to occur polynomially as often inD'.[6]
The average-case analogue toNP-completeness isdistNP-completeness. A distributional problem(L′,D′) isdistNP-complete if(L′,D′) is indistNP and for every(L,D) indistNP,(L,D) is average-case reducible to(L′,D′).[7]
An example of adistNP-complete problem is the BoundedHalting Problem,(BH,D) (for anyP-computableD) defined as follows:
In his original paper, Levin showed an example of a distributional tiling problem that is average-caseNP-complete.[5] A survey of knowndistNP-complete problems is available online.[6]
One area of active research involves finding newdistNP-complete problems. However, finding such problems can be complicated due to a result of Gurevich which shows that any distributional problem with a flat distribution cannot bedistNP-complete unlessEXP =NEXP.[8] (A flat distributionμ is one for which there exists anε > 0 such that for anyx,μ(x) ≤ 2−|x|ε.) A result by Livne shows that all naturalNP-complete problems haveDistNP-complete versions.[9] However, the goal of finding a natural distributional problem that isDistNP-complete has not yet been achieved.[10]
As mentioned above, much early work relating to average-case complexity focused on problems for which polynomial-time algorithms already existed, such as sorting. For example, many sorting algorithms which utilize randomness, such asQuicksort, have a worst-case running time ofO(n2), but an average-case running time ofO(n log(n)), wheren is the length of the input to be sorted.[2]
For most problems, average-case complexity analysis is undertaken to find efficient algorithms for a problem that is considered difficult in the worst-case. In cryptographic applications, however, the opposite is true: the worst-case complexity is irrelevant; we instead want a guarantee that the average-case complexity of every algorithm which "breaks" the cryptographic scheme is inefficient.[11][page needed]
Thus, all secure cryptographic schemes rely on the existence ofone-way functions.[3] Although the existence of one-way functions is still anopen problem, many candidate one-way functions are based on hard problems such asinteger factorization or computing thediscrete log. Note that it is not desirable for the candidate function to beNP-complete since this would only guarantee that there is likely no efficient algorithm for solving the problem in the worst case; what we actually want is a guarantee that no efficient algorithm can solve the problem over random inputs (i.e. the average case). In fact, both the integer factorization and discrete log problems are inNP ∩coNP, and are therefore not believed to beNP-complete.[7] The fact that all of cryptography is predicated on the existence of average-case intractable problems inNP is one of the primary motivations for studying average-case complexity.
Yao's principle, from a 1978 paper byAndrew Yao, shows that for broad classes of computational problems, average-case complexity for a hard input distribution and adeterministic algorithm adapted to that distribution is the same thing as expected complexity for a fast randomized algorithm and its worst-case input.[12]
In 1990, Impagliazzo and Levin showed that if there is an efficient average-case algorithm for adistNP-complete problem under the uniform distribution, then there is an average-case algorithm for every problem inNP under any polynomial-time samplable distribution.[13] Applying this theory to natural distributional problems remains an outstanding open question.[3]
In 1992, Ben-David et al. showed that if all languages indistNP have good-on-average decision algorithms, they also have good-on-average search algorithms. Further, they show that this conclusion holds under a weaker assumption: if every language inNP is easy on average for decision algorithms with respect to the uniform distribution, then it is also easy on average for search algorithms with respect to the uniform distribution.[14] Thus, cryptographic one-way functions can exist only if there aredistNP problems over the uniform distribution that are hard on average for decision algorithms.
In 1993, Feigenbaum and Fortnow showed that it is not possible to prove, under non-adaptive random reductions, that the existence of a good-on-average algorithm for adistNP-complete problem under the uniform distribution implies the existence of worst-case efficient algorithms for all problems inNP.[15] In 2003, Bogdanov and Trevisan generalized this result to arbitrary non-adaptive reductions.[16] These results show that it is unlikely that any association can be made between average-case complexity and worst-case complexity via reductions.[3]
{{citation}}: CS1 maint: work parameter with ISBN (link)Pedagogical presentations:
{{citation}}: CS1 maint: work parameter with ISBN (link)The literature of average case complexity includes the following work: