60 add avl tree as an alternative backend data structures for copy efficent persistent data structures#61
Open
kaizhx wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an initial path-copying persistent AVL tree map implementation based on the existing
PathCopyingPersistentTreeMapwhich is based on a LLRB tree.Changes
Changes to the existing tree map implementation focus on replacing LLRB specific logic with their AVL counterparts:
PathCopyingPersistentAvlTreeMaprebalance().restructure().(See https://www.csl.mtu.edu/cs2321/www/newLectures/20_AVL_Tree.html for more information on restructuring algorithm)
checkAssertions()to validate AVL height and balance invariants instead of LLRB invariants.putAndCopy()to use AVL rebalancing.removeAndCopy()to use standard BST deletion followed by AVL rebalancing.restructure()for the two child deletion case, choosing the predecessor/successor replacement based on the larger subtree height.(See https://arxiv.org/pdf/2406.05162 for Browns improved deletion algorithm)
Reused structures
The implementation intentionally keeps most of the existing persistent tree map structure unchanged where logic is not tied to the LLRB tree implementation and only requires the existence of a binary search tree.