From 4132522d4a2e971a4947006448df12710781e151 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 1 Jun 2018 08:28:36 +0300 Subject: [PATCH] Set up node comparator for BST. --- .../tree/binary-search-tree/BinarySearchTree.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/data-structures/tree/binary-search-tree/BinarySearchTree.js b/src/data-structures/tree/binary-search-tree/BinarySearchTree.js index 385b471f..e70950f9 100644 --- a/src/data-structures/tree/binary-search-tree/BinarySearchTree.js +++ b/src/data-structures/tree/binary-search-tree/BinarySearchTree.js @@ -6,6 +6,9 @@ export default class BinarySearchTree { */ constructor(nodeValueCompareFunction) { this.root = new BinarySearchTreeNode(null, nodeValueCompareFunction); + + // Steal node comparator from the root. + this.nodeComparator = this.root.nodeComparator; } /**