Skip to content

Instantly share code, notes, and snippets.

@helabenkhalfallah
Last active February 10, 2024 21:19
Show Gist options
  • Save helabenkhalfallah/cee97acbd24dae7225b3ff81ca41d71d to your computer and use it in GitHub Desktop.
Save helabenkhalfallah/cee97acbd24dae7225b3ff81ca41d71d to your computer and use it in GitHub Desktop.
BinarySearchTreeNode
class BinarySearchTreeNode {
constructor(key, value = key, parent = null) {
this.key = key;
this.value = value;
this.parent = parent;
this.left = null;
this.right = null;
}
get isLeaf() {
return this.left === null && this.right === null;
}
get hasChildren() {
return !this.isLeaf;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment