Skip to content

Commit

Permalink
small fix in rotations
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrodshn committed Nov 23, 2019
1 parent 8f98088 commit 9d038bd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redblacktrees/red_black_trees.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func (t *RedBlackTree) RotateLeft(node *Node) {
node.parent = y
if t.root == node {
t.root = y
} else {
if node.parent.right == node {
node.parent.right = y
} else {
node.parent.left = y
}
}
}

Expand All @@ -44,5 +50,11 @@ func (t *RedBlackTree) RotateRight(node *Node) {
node.parent = y
if t.root == node {
t.root = y
} else {
if node.parent.right == node {
node.parent.right = y
} else {
node.parent.left = y
}
}
}

0 comments on commit 9d038bd

Please sign in to comment.