Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit863dbdb

Browse files
committed
Fix issuetrekhleb#98.
1 parentfafa52c commit863dbdb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎src/data-structures/tree/binary-search-tree/BinarySearchTreeNode.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ export default class BinarySearchTreeNode extends BinaryTreeNode {
132132
}
133133
}
134134

135+
// Clear the parent of removed node.
136+
nodeToRemove.parent=null;
137+
135138
returntrue;
136139
}
137140

‎src/data-structures/tree/binary-search-tree/__test__/BinarySearchTreeNode.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,13 @@ describe('BinarySearchTreeNode', () => {
243243

244244
expect(bstNode.findMin().value).toEqual(obj1);
245245
});
246+
247+
it('should abandon removed node',()=>{
248+
constrootNode=newBinarySearchTreeNode('foo');
249+
rootNode.insert('bar');
250+
constchildNode=rootNode.find('bar');
251+
rootNode.remove('bar');
252+
253+
expect(childNode.parent).toBeNull();
254+
});
246255
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp