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.[1]
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.
The number of comparisons needed to solve the problem of size , in a comparison-based model of computation such as a decision tree or algebraic decision tree, is . Here, invokes big theta notation, meaning that the problem can be solved in a number of comparisons proportional to (a linearithmic function) and that all solutions require this many comparisons.[2] In these models of computation, the input numbers may not be used to index the computer's memory (as in the hash table solution) but may only be accessed by computing and comparing simple algebraic functions of their values. For these models, an algorithm based on comparison sort solves the problem within a constant factor of the best possible number of comparisons. The same lower bound applies as well to the expected number of comparisons in the randomizedalgebraic decision tree model.[3][4]
If the elements in the problem are real numbers, the decision-tree lower bound extends to the real random-access machine model with an instruction set that includes addition, subtraction and multiplication of real numbers, as well as comparison and either division or remaindering ("floor").[5] It follows that the problem's complexity in this model is also . This RAM model covers more algorithms than the algebraic decision-tree model, as it encompasses algorithms that use indexing into tables. However, in this model all program steps are counted, not just decisions.
単一テープの決定性チューリングマシンは、それぞれm ≥ log nビットのn個の要素に対して、 O ( n 2 m ( m +2–log n ))の時間で問題を解くことができるが、非決定性マシンでは時間計算量はO ( nm ( n + log m ))である。[ 6 ]
量子アルゴリズムはこの問題をより速く解決できます。クエリ。最適なアルゴリズムはAndris Ambainisによるものです。[ 7 ] Yaoyun Shi は、範囲のサイズが十分に大きい場合にタイトな下限を最初に証明しました。[ 8 ] Ambainis [ 9 ]と Kutin [ 10 ]は、独立して (異なる証明を介して) 彼の研究を拡張し、すべての関数の下限を取得しました。
より多く出現する要素サイズが のマルチセットで 回比較ベースのアルゴリズムであるMisra–Griesヘビーヒッターアルゴリズムによって、時間内に見つけることができる。要素の区別問題は、この問題の特殊なケースであり、この時間は、決定木モデルの計算において最適である。[ 11 ]