MCPcopy
hub / github.com/keon/algorithms / add

Method add

algorithms/data_structures/union_find.py:38–46  ·  view source on GitHub ↗

Add a new singleton set containing the given element. Args: element: The element to add.

(self, element: object)

Source from the content-addressed store, hash-verified

36 self.count: int = 0
37
38 def add(self, element: object) -> None:
39 """Add a new singleton set containing the given element.
40
41 Args:
42 element: The element to add.
43 """
44 self.parents[element] = element
45 self.size[element] = 1
46 self.count += 1
47
48 def root(self, element: object) -> object:
49 """Find the root representative of the set containing element.

Callers 15

num_islandsFunction · 0.95
subsetsFunction · 0.80
remove_dupsFunction · 0.80
word_patternFunction · 0.80
is_isomorphicFunction · 0.80
_backtrackFunction · 0.80
_backtrackFunction · 0.80
three_sumFunction · 0.80
remove_duplicatesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected