File tree Expand file tree Collapse file tree 1 file changed +4
-11
lines changed Expand file tree Collapse file tree 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';
33import RED from '../color/RED.js' ;
44import Node from '../types/Node.js' ;
55
6- import replace_node from './replace_node.js' ;
76import delete_case1 from './delete_case1.js' ;
87
98import prune from './prune.js' ;
@@ -30,20 +29,14 @@ const delete_no_child = (n) => {
3029 return n . parent ;
3130 }
3231
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-
4132 // If n is black, deleting it reduces the black-height of every path going
4233 // 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 ) ;
4437
4538 // Delete mocked leaf
46- prune ( leaf ) ;
39+ prune ( n ) ;
4740 return subtree ;
4841} ;
4942
You can’t perform that action at this time.
0 commit comments