3.4 Set

Time Complexity

  • >Sets are implemented using hash tables, so pretty much all operations should be O(1) and O(n) in the worst case which is when Hash collision occurs.
  • >Adding, checking (with the in operator) and removing are O(1).
  • >Iterating is O(n).
  • >Union is O(m+n).
  • >Intersection is O(min(m,n)), worst is O(m*n).

3.4.1 FrozenSet