Skip to content

Commit

Permalink
Make insert new key as red node with two empty sub-trees clear
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinyu95 committed Jan 21, 2022
1 parent 93a2f4c commit 25bff64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datastruct/tree/red-black-tree/rbtree-en.tex
Expand Up @@ -275,7 +275,7 @@ \section{Insert}
\end{array}
\ee

If the tree is empty, we create a red leaf of $k$; otherwise, let the sub-trees and the key be $l$, $r$, $k'$, we compare $k$ and $k'$, then recursively insert $k$ to a sub-tree. After that, we call $balance$ to fix the coloring, then force the root to be black finally.
If the tree is empty, we create a red node of $k$ with two empty sub-trees; otherwise, let the sub-trees and the key be $l$, $r$, $k'$, we compare $k$ and $k'$, then recursively insert $k$ to a sub-tree. After that, we call $balance$ to fix the coloring, then force the root to be black finally.

\be
makeBlack\ (\mathcal{C}, l, k, r) = (\mathcal{B}, l, k, r)
Expand Down
2 changes: 1 addition & 1 deletion datastruct/tree/red-black-tree/rbtree-zh-cn.tex
Expand Up @@ -278,7 +278,7 @@ \section{插入}
\end{array}
\ee

如果树为空,我们为$k$创建一个红色叶子节点;否则,令树的左右分支和值分别为$l$$r$$k'$。比较$k$$k'$的大小,递归地将$k$插入到子树中。然后用$balance$修复平衡性。最后强制把根节点染成黑色。
如果树为空,我们为$k$创建一个红色节点,它的两个分枝都为空;否则,令树的左右分支和值分别为$l$$r$$k'$。比较$k$$k'$的大小,递归地将$k$插入到子树中。然后用$balance$修复平衡性。最后强制把根节点染成黑色。

\be
makeBlack\ (\mathcal{C}, l, k, r) = (\mathcal{B}, l, k, r)
Expand Down

0 comments on commit 25bff64

Please sign in to comment.