Skip to content

Commit

Permalink
Merge pull request #172 from vcheckzen/master
Browse files Browse the repository at this point in the history
fix(rbtree): typos of finding the brother of a node who is a right child of his parent
  • Loading branch information
hunterhug authored Jun 17, 2024
2 parents 50aa1e0 + dd3afa6 commit d8d3ba5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions algorithm/search/rb_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func (tree *RBTree) fixAfterDeletion(node *RBTNode) {
} else {
// 要删除的节点在父亲右边,对应图例3,4
// 找出兄弟
brother := RightOf(ParentOf(node))
brother := LeftOf(ParentOf(node))

// 兄弟是红色的,对应图例3,那么兄弟变黑,父亲变红,然后对父亲右旋,进入图例41,42,43
if IsRed(brother) {
Expand Down Expand Up @@ -1102,7 +1102,7 @@ func (tree *RBTree) fixAfterDeletion(node *RBTNode) {
} else {
// 要删除的节点在父亲右边,对应图例3,4
// 找出兄弟
brother := RightOf(ParentOf(node))
brother := LeftOf(ParentOf(node))

// 兄弟是红色的,对应图例3,那么兄弟变黑,父亲变红,然后对父亲右旋,进入图例41,42,43
if IsRed(brother) {
Expand Down Expand Up @@ -1682,7 +1682,7 @@ func (tree *RBTree) fixAfterDeletion(node *RBTNode) {
} else {
// 要删除的节点在父亲右边,对应图例3,4
// 找出兄弟
brother := RightOf(ParentOf(node))
brother := LeftOf(ParentOf(node))

// 兄弟是红色的,对应图例3,那么兄弟变黑,父亲变红,然后对父亲右旋,进入图例41,42,43
if IsRed(brother) {
Expand Down
2 changes: 1 addition & 1 deletion code/rbt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (tree *RBTree) fixAfterDeletion(node *RBTNode) {
} else {
// 要删除的节点在父亲右边,对应图例3,4
// 找出兄弟
brother := RightOf(ParentOf(node))
brother := LeftOf(ParentOf(node))

// 兄弟是红色的,对应图例3,那么兄弟变黑,父亲变红,然后对父亲右旋,进入图例41,42,43
if IsRed(brother) {
Expand Down

0 comments on commit d8d3ba5

Please sign in to comment.