You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following test (that doesn't exist in codebase) fails with the current BST remove()
it('should insert and remove single node properly',function(){varbTree=newBinaryTree();bTree.insert(15);varnode=bTree.find(15);bTree.remove(node);expect(bTree._root).toBe(null);});
Here's the issue explained in comments
// this is called in .remove()
this._replaceChild(node._parent, node, null); // node._parent is null since the node is the root, node is valid
..
..
..
function (parent, oldChild, newChild) {
if (!parent) { //parent param is null, enter if
this._root = newChild; //assigns null to root
this._root._parent = null; // null._parent throws error
} else {
if (parent._left === oldChild) {
parent._left = newChild;
} else {
parent._right = newChild;
}
if (newChild) {
newChild._parent = parent;
}
}
I've got a fix in place, a bunch of tests for BST, and will submit a PR once #45 clears (changes are on my local master).
The text was updated successfully, but these errors were encountered:
The following test (that doesn't exist in codebase) fails with the current BST remove()
Here's the issue explained in comments
I've got a fix in place, a bunch of tests for BST, and will submit a PR once #45 clears (changes are on my local master).
The text was updated successfully, but these errors were encountered: