We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b6a77ad commit 26aea78Copy full SHA for 26aea78
src/deletion/delete_one_child.js
@@ -9,6 +9,14 @@ import replace_node from './replace_node.js';
9
* Delete a node <code>n</code> with one non-leaf left child and one leaf right
10
* child.
11
*
12
+ * p
13
+ * |
14
+ * n (BLACK)
15
+ * / \
16
+ * RED -
17
18
+ * - -
19
+ *
20
* Precondition:
21
* - n has exactly one non-leaf child.
22
* - n is not the root
@@ -33,6 +41,8 @@ const delete_one_child = (n) => {
33
41
// We can easily fix this when its only child is an
34
42
// internal RED node: change the color of the child to black and
35
43
// replace n with it.
44
+ // TODO we could know n's direction depending whether swap_left or
45
+ // swap_non_adjacent has been called upstream.
36
46
replace_node(n, child);
37
47
child._color = BLACK;
38
48
};
0 commit comments