File tree 1 file changed +4
-11
lines changed
1 file changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import BLACK from '../color/BLACK.js';
3
3
import RED from '../color/RED.js' ;
4
4
import Node from '../types/Node.js' ;
5
5
6
- import replace_node from './replace_node.js' ;
7
6
import delete_case1 from './delete_case1.js' ;
8
7
9
8
import prune from './prune.js' ;
@@ -30,20 +29,14 @@ const delete_no_child = (n) => {
30
29
return n . parent ;
31
30
}
32
31
33
- // Mock leaf since there is no left child
34
- // We use key = n.key to avoid mixing types, but this property is never
35
- // accessed.
36
- const leaf = new Node ( BLACK , n . key ) ;
37
-
38
- // Replace n with the mocked leaf
39
- replace_node ( n , leaf ) ;
40
-
41
32
// If n is black, deleting it reduces the black-height of every path going
42
33
// through it by 1. The leaf is black, so there are more things to fix.
43
- const subtree = delete_case1 ( leaf ) ;
34
+ // NOTE We temporarily keep n in the tree to mock a leaf, since n does not
35
+ // have children.
36
+ const subtree = delete_case1 ( n ) ;
44
37
45
38
// Delete mocked leaf
46
- prune ( leaf ) ;
39
+ prune ( n ) ;
47
40
return subtree ;
48
41
} ;
49
42
You can’t perform that action at this time.
0 commit comments