Compare commits

..

3 commits

Author SHA1 Message Date
Bruno BELANYI dfdd65cd27 posts: generic-flyweight: fix typo
All checks were successful
ci/woodpecker/push/deploy/2 Pipeline was successful
2024-06-27 10:32:27 +00:00
Bruno BELANYI 3226918995 posts: polymorphic-flyweight: fix typo 2024-06-27 10:32:26 +00:00
Bruno BELANYI eb2245db21 posts: union-find: fix typos 2024-06-27 10:32:26 +00:00
2 changed files with 3 additions and 3 deletions

View file

@ -86,7 +86,7 @@ A naive Implementation of `find(...)` is simple enough to write:
```python
def find(self, elem: int) -> int:
# If `elem` is its own parent, then it is the root of the tree
if (parent: = self._parent[elem]) == elem:
if (parent := self._parent[elem]) == elem:
return elem
# Otherwise, recurse on the parent
return self.find(parent)
@ -98,7 +98,7 @@ do a small optimization called _path splitting_.
```python
def find(self, elem: int) -> int:
while (parent: = self._parent[elem]) != elem:
while (parent := self._parent[elem]) != elem:
# Replace each parent link by a link to the grand-parent
elem, self._parent[elem] = parent, self._parent[parent]
return elem

@ -1 +1 @@
Subproject commit d545effed9949bf834eaed09ad423ec3e030794f
Subproject commit 5da913dc46d2dadcaf6548256238c58c504476de