Compare commits
5 commits
dfdd65cd27
...
23a2d4d249
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 23a2d4d249 | ||
Bruno BELANYI | 03866def1d | ||
Bruno BELANYI | c3fced1626 | ||
Bruno BELANYI | 8dc1221475 | ||
Bruno BELANYI | 60a8ea994a |
|
@ -104,8 +104,8 @@ def find(self, elem: int) -> int:
|
|||
return elem
|
||||
```
|
||||
|
||||
This flattens the links so that each node links directly to the root, making
|
||||
each subsequent `find(...)` constant time.
|
||||
This flattens the chain so that each node links more directly to the root (the
|
||||
length is reduced by half), making each subsequent `find(...)` faster.
|
||||
|
||||
Other compression schemes exist, along the spectrum between faster shortening
|
||||
the chain faster earlier, or updating `_parent` fewer times per `find(...)`.
|
||||
|
|
Loading…
Reference in a new issue