membership test

Asking whether a collection contains a given item, written `x in collection` in Python.

In more detail

The cost depends entirely on the structure: O(n) for a list, O(log n) for a sorted list with bisect, and O(1) on average for a set or dict. A Bloom filter answers membership approximately in very little memory. For workloads dominated by membership tests, a set is almost always the right choice.

Related terms

Taught in

References