Skip to content

Commit a7638f3

Browse files
authored
Update progressive_set_intersection.py
1 parent 05d06f5 commit a7638f3

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

data_structures/disjoint_set/progressive_set_intersection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"""Progressive multi-set intersection optimized for imbalanced sets."""
22

3-
from typing import Set
4-
5-
6-
def progressive_set_intersection(*sets: Set) -> Set:
3+
def progressive_set_intersection(*sets: set) -> set:
74
"""
85
Compute the intersection of multiple sets efficiently.
96
@@ -17,6 +14,7 @@ def progressive_set_intersection(*sets: Set) -> Set:
1714
heuristic for educational purposes.
1815
1916
Time Complexity: Better than naive in practice due to early pruning.
17+
Space Complexity: O(size of smallest set)
2018
2119
Examples:
2220
>>> progressive_set_intersection({1, 2, 3}, {2, 3, 4}, {2, 5})
@@ -42,6 +40,6 @@ def progressive_set_intersection(*sets: Set) -> Set:
4240
for current_set in sorted_sets[1:]:
4341
if not result:
4442
return set()
45-
result &= current_set # Efficient in-place intersection
43+
result &= current_set # Efficient in-place intersection
4644

4745
return result

0 commit comments

Comments
 (0)