Compare commits

..

6 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
Bruno BELANYI fa2849bdba Add Union-Find post
All checks were successful
ci/woodpecker/push/deploy/2 Pipeline was successful
2024-06-26 11:13:58 +00:00
Bruno BELANYI 62c4506eef posts: union-find: add 'union' 2024-06-26 11:13:48 +00:00
Bruno BELANYI 11646adee2 posts: union-find: add 'find' 2024-06-26 11:13:48 +00:00

View file

@ -104,8 +104,8 @@ def find(self, elem: int) -> int:
return elem return elem
``` ```
This flattens the chain so that each node links more directly to the root (the This flattens the links so that each node links directly to the root, making
length is reduced by half), making each subsequent `find(...)` faster. each subsequent `find(...)` constant time.
Other compression schemes exist, along the spectrum between faster shortening Other compression schemes exist, along the spectrum between faster shortening
the chain faster earlier, or updating `_parent` fewer times per `find(...)`. the chain faster earlier, or updating `_parent` fewer times per `find(...)`.