Removing an element from a red-black tree sometimes modifies the remaining key-value pairs
See original GitHub issueUsing @collectable/red-black-tree@3.7.0
with Node 8.1.3:
const RBT = require("@collectable/red-black-tree");
let tree = RBT.empty();
tree = RBT.set(1, 'one', tree);
tree = RBT.set(3, 'three', tree);
tree = RBT.set(2, 'two', tree);
tree = RBT.remove(2, tree);
console.log(RBT.get(3, tree));
Expected output:
three
Actual output:
two
Issue Analytics
- State:
- Created 6 years ago
- Comments:21 (21 by maintainers)
Top Results From Across the Web
Deletion in a Red-Black Tree - Programiz
Deleting an element from a Red-Black Tree ... This operation removes a node from the tree. After deleting a node, the red-black property...
Read more >Deletion in Red-Black Tree - GeeksforGeeks
In delete, the main violated property is, change of black height in subtrees as deletion of a black node may cause reduced black...
Read more >Binary Search Trees: BST Explained with Examples
That is why self-balancing trees (AVL, red-black, etc.) ... the data is less than the key value, search for the element in the...
Read more >Deleting a whole subtree of a red-black tree would keep its ...
When you delete one element from a red-black tree it takes O(log n) time, where n is the number of elements currently in...
Read more >Red Black Tree Deletion - YouTube
... tree. https://www.facebook.com/tusharroy25https://github.com/mission-peace/interview/blob/master/src/com/interview/tree/ RedBlackTree.ja.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok it’s all in, with new packages published. Readme files and so forth have not been updated at this stage. Let me know if you have any questions, and feel free to revise your pull requests after updating your code.
That would work, but it’d be less efficient because you’d be performing two iterations instead of one; first to iterate and find the keys to remove, and second to iterate and perform the removals.