aboutsummaryrefslogtreecommitdiff
path: root/PuzzleApplet.java
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-20 17:13:47 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-20 18:42:50 +0100
commit68d242c5875ec1133429c656520b2d173c05e387 (patch)
tree107eee5eba7cddf3f133875f8a729389013b7e42 /PuzzleApplet.java
parentc5e253a9f9d3d651227ccad56e2c7526ee1f3eba (diff)
downloadpuzzles-68d242c5875ec1133429c656520b2d173c05e387.zip
puzzles-68d242c5875ec1133429c656520b2d173c05e387.tar.gz
puzzles-68d242c5875ec1133429c656520b2d173c05e387.tar.bz2
puzzles-68d242c5875ec1133429c656520b2d173c05e387.tar.xz
Actually rewrite the dsf implementation.
This rewrite improves the core data structure implementation in two ways. Firstly, when merging two equivalence classes, we check their relative sizes, and choose the larger class's canonical element to be the overall root of the new class tree. This minimises the number of overlong paths to the root after the merge. Secondly, we defer path compression until _after_ the two classes are merged, rather than do it beforehand (via using edsf_canonify as a subroutine) and then have to do it wastefully again afterwards. The size-based root selection was what we _used_ to do, and delivers the better asymptotic performance. I reverted it so that Keen could track the min of each equivalence class. But since then I've realised you can have the asymptotic goodness _and_ min-tracking if you store the minima separately from the main data structure. So now Keen does that, and other clients don't have to pay the cost. Similarly, the flip tracking is now a cost that only users of flip dsfs have to pay, because a normal one doesn't store that information at all.
Diffstat (limited to 'PuzzleApplet.java')
0 files changed, 0 insertions, 0 deletions