Content deleted Content added
m WP:CHECKWIKI error fixes + general fixes using AWB (7896) |
m clean up citations |
||
Line 1:
In [[computational complexity theory]], the '''element distinctness problem''' or '''element uniqueness problem''' is the problem of determining whether all the elements of a list are distinct.
It is a well studied problem in many different models of computation. The problem may be solved by [[sorting]] the list and then checking if there are any consecutive equal elements; it may also be solved in linear expected time by a [[randomized algorithm]] that inserts each item into a [[hash table]] and compares only those elements that are placed in the same hash table cell.<ref>{{
| last1 = Gil | first1 = J.
| last2 = Meyer auf der Heide | first2 = F.
| last3 = Wigderson | first3 = A. | author3-link = Avi Wigderson
| contribution = Not all keys can be hashed in constant time
| doi = 10.1145/100216.100247
| pages = 244–253
| title = [[Symposium on Theory of Computing|Proc. 22nd ACM Symposium on Theory of Computing
| year = 1990}}.</ref>
It is known that the problem's [[time complexity]] is [[Big O notation|Θ]](''n'' log ''n''), i.e., both the upper and lower bounds on its time complexity are of order of the [[linearithmic function]] in the [[algebraic decision tree]] [[model of computation]],<ref>
The same lower bound was later proved for the [[randomized complexity|randomized]] [[algebraic decision tree]] model.<ref>{{
It is also known that [[quantum algorithm]]s can solve this problem faster in <math>\Theta\left(n^{2/3}\right)</math> queries. The optimal algorithm is by [[Andris Ambainis]],<ref>{{
Several lower bounds in computational complexity are proved by reducing the element distinctness problem to the problem in question, i.e., by demonstrating that the solution of the element uniqueness problem may be quickly found after solving the problem in question.
Line 23:
==Generalization: Finding repeated elements==
Elements that occur more than ''n''/''k'' times in a multiset of size n may be found in time O(''n'' log ''k''). The element distinctness problem is a special case of ''k''=''n''. This algorithm is optimal under the [[decision tree model]] of computation.<ref>{{citation|first1=J.
The algorithm is a generalization of the one for a special case of ''k''=2, which had a rather convoluted history of publication.<ref name=bm>
The above algorithms rely only on the test of identity of the elements. If sorting is allowed, previously known [[order statistics]] finding algorithms may be exploited. For example, for ''k''=2, a [[median]] may be found first in [[linear time]], and then it may be easily tested whether there are more than ''n''/2 median elements. However the above algorithms require fewer comparisons than the order statistics algorithms.<ref name=bm/>
|