Compare commits
6 commits
23a2d4d249
...
dfdd65cd27
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | dfdd65cd27 | ||
Bruno BELANYI | 3226918995 | ||
Bruno BELANYI | eb2245db21 | ||
Bruno BELANYI | fa2849bdba | ||
Bruno BELANYI | 62c4506eef | ||
Bruno BELANYI | 11646adee2 |
|
@ -104,8 +104,8 @@ def find(self, elem: int) -> int:
|
|||
return elem
|
||||
```
|
||||
|
||||
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.
|
||||
This flattens the links so that each node links directly to the root, making
|
||||
each subsequent `find(...)` constant time.
|
||||
|
||||
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