What is the complexity of bitwise operation of two sets?

Viewed 47

I was looking at the following line of code

{1,5,3,4,2}&{3, 4, 5, 6, 7} and was curious what the complexity of the bitwise operation & of two sets is in Python

I'd like to know how the bitwise operation on sets is performed under the hood.

1 Answers

The & operator is just a shorthand for set.intersection it is not "bitwise" it is just another usage of &.

The time complexity is O(min(n, m)) when n and m are the lengths of the two sets, respectively.

The source code written in C can be seen here.

Related