question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing an element from a red-black tree sometimes modifies the remaining key-value pairs

See original GitHub issue

Using @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:closed
  • Created 6 years ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
axefrogcommented, Jul 11, 2017

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.

1reaction
axefrogcommented, Jul 11, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found