We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
trekhleb
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the test file BinarySearchTree.test.js add a test as below:
it('should remove root node correctly', () => { const bst = new BinarySearchTree(); bst.insert(1).insert(2); expect(bst.toString()).toBe('1,2'); bst.remove(1); bst.remove(2); expect(bst.toString()).toBe(''); bst.insert(5); expect(bst.toString()).toBe('5'); });
It will report an error:
Expected: "5" Received: ",5" 15 | expect(bst.toString()).toBe(''); 16 | bst.insert(5); > 17 | expect(bst.toString()).toBe('5'); | ^ 18 | }); 19 | }); 20 |
Before bst.insert(5) bst is:
bst.insert(5)
BinarySearchTree { root: BinarySearchTreeNode { left: null, right: null, parent: null, value: undefined, meta: HashTable { buckets: [Array], keys: {} }, nodeComparator: Comparator { compare: [Function: defaultCompareFunction] }, compareFunction: undefined, nodeValueComparator: Comparator { compare: [Function: defaultCompareFunction] } }, nodeComparator: Comparator { compare: [Function: defaultCompareFunction] } }
after that, bst is:
BinarySearchTree { root: BinarySearchTreeNode { left: null, right: BinarySearchTreeNode { left: null, right: null, parent: [Circular], value: 5, meta: [Object], nodeComparator: [Object], compareFunction: undefined, nodeValueComparator: [Object] }, parent: null, value: undefined, meta: HashTable { buckets: [Array], keys: {} }, nodeComparator: Comparator { compare: [Function: defaultCompareFunction] }, compareFunction: undefined, nodeValueComparator: Comparator { compare: [Function: defaultCompareFunction] } }, nodeComparator: Comparator { compare: [Function: defaultCompareFunction] } }
This looks like a bug in design, we should remove the node rather than just set the node value to be undefined.
The text was updated successfully, but these errors were encountered:
Can I work on it? @hifizz
Sorry, something went wrong.
Can i work on this?@hifizz
Sure
No branches or pull requests
In the test file BinarySearchTree.test.js add a test as below:
It will report an error:
Before
bst.insert(5)
bst is:after that, bst is:
This looks like a bug in design, we should remove the node rather than just set the node value to be undefined.
The text was updated successfully, but these errors were encountered: