Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.1.8] - 2021-04-02
### Fixed
- update the removed node value with min right one in avl tree.

## [3.1.7] - 2021-01-26
### Fixed
- update the removed node value with min right one.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datastructures-js/binary-search-tree",
"version": "3.1.7",
"version": "3.1.8",
"description": "binary search tree & avl tree (self balancing tree) implementation in javascript",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/avlTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ class AvlTree extends BinarySearchTree {

const minRight = this.min(node.getRight());
node.setKey(minRight.getKey());
node.setValue(minRight.getValue());
return this.remove(minRight.getKey(), minRight);
}
}
Expand Down
1 change: 1 addition & 0 deletions test/avlTree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ describe('AvlTree tests', () => {

avlTree.remove(20);
expect(avlTree.root().getKey()).to.equal(40);
expect(avlTree.root().getValue()).to.equal('n4');
expect(avlTree.root().getLeft().getKey()).to.equal(15);

avlTree.remove(40);
Expand Down