Skip to content
New issue

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

Adding of a method that get the successor of a node inside the birany search tree #589

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Prev Previous commit
using the built in comparator of BinarySearchTreeNode class to compar…
…e some value inside the function successor for getting the successor of a node
dilane3 committed Jan 25, 2022
commit 815daefc915466262062a9bcad640df56242bc5b
Original file line number Diff line number Diff line change
@@ -160,7 +160,10 @@ export default class BinarySearchTreeNode extends BinaryTreeNode {
let currentNode = this;
let { parent } = currentNode;

while (parent !== null && parent.right && parent.right.value === currentNode.value) {
while (!this.nodeComparator.equal(parent, null)
&& parent.right
&& this.nodeComparator.equal(parent.right.value, currentNode.value)
) {
currentNode = parent;
parent = currentNode.parent;
}