Skip to content

Commit 26aea78

Browse files
📚 docs(delete_one_child): Add input illustration and TODO note.
1 parent b6a77ad commit 26aea78

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/deletion/delete_one_child.js

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ import replace_node from './replace_node.js';
99
* Delete a node <code>n</code> with one non-leaf left child and one leaf right
1010
* child.
1111
*
12+
* p
13+
* |
14+
* n (BLACK)
15+
* / \
16+
* RED -
17+
* / \
18+
* - -
19+
*
1220
* Precondition:
1321
* - n has exactly one non-leaf child.
1422
* - n is not the root
@@ -33,6 +41,8 @@ const delete_one_child = (n) => {
3341
// We can easily fix this when its only child is an
3442
// internal RED node: change the color of the child to black and
3543
// 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.
3646
replace_node(n, child);
3747
child._color = BLACK;
3848
};

0 commit comments

Comments
 (0)