@@ -6,7 +6,6 @@ class BinarySearchTree {
6
6
constructor ( value ) {
7
7
if ( ! value ) throw new Error ( 'Root node value required' ) ;
8
8
this . root = new Node ( value ) ;
9
- this . BSTUtils = BSTUtils ;
10
9
}
11
10
12
11
isEmpty ( ) {
@@ -16,37 +15,37 @@ class BinarySearchTree {
16
15
/** Layered methods to simplify the BST API using utils under the hood */
17
16
18
17
add ( value ) {
19
- return this . BSTUtils . insert ( this . root , value ) ;
18
+ return BSTUtils . insert ( this . root , value ) ;
20
19
}
21
20
22
21
preorder ( ) {
23
- return this . BSTUtils . preorder ( this . root ) ;
22
+ return BSTUtils . preorder ( this . root ) ;
24
23
}
25
24
26
25
postorder ( ) {
27
- return this . BSTUtils . postorder ( this . root ) ;
26
+ return BSTUtils . postorder ( this . root ) ;
28
27
}
29
28
30
29
inorder ( ) {
31
- return this . BSTUtils . inorder ( this . root ) ;
30
+ return BSTUtils . inorder ( this . root ) ;
32
31
}
33
32
34
33
search ( value ) {
35
- return this . BSTUtils . search ( this . root , value ) ;
34
+ return BSTUtils . search ( this . root , value ) ;
36
35
}
37
36
38
37
getMinimum ( ) {
39
- const minNode = this . BSTUtils . findMinNode ( this . root ) ;
38
+ const minNode = BSTUtils . findMinNode ( this . root ) ;
40
39
return minNode . value ;
41
40
}
42
41
43
42
getMaximum ( ) {
44
- const maxNode = this . BSTUtils . findMaxNode ( this . root ) ;
43
+ const maxNode = BSTUtils . findMaxNode ( this . root ) ;
45
44
return maxNode . value ;
46
45
}
47
46
48
47
remove ( value ) {
49
- this . root = this . BSTUtils . delete ( this . root , value ) ;
48
+ this . root = BSTUtils . delete ( this . root , value ) ;
50
49
}
51
50
}
52
51
0 commit comments