Skip to content

Commit

Permalink
Fix reversed name (rotation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshi Nakamura committed Feb 5, 2012
1 parent 4154dd4 commit a1372ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/avl_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ def rotate
case @left.height - @right.height
when +2
if @left.left.height < @left.right.height
@left = @left.rotate_right
@left = @left.rotate_left
end
root = rotate_left
root = rotate_right
when -2
if @right.left.height > @right.right.height
@right = @right.rotate_left
@right = @right.rotate_right
end
root = rotate_right
root = rotate_left
else
root = self
end
Expand All @@ -238,7 +238,7 @@ def rotate
# / \ / \
# c E a c
#
def rotate_right
def rotate_left
root = @right
@right = root.left
root.left = self
Expand All @@ -255,7 +255,7 @@ def rotate_right
# / \ / \
# A c c e
#
def rotate_left
def rotate_right
root = @left
@left = root.right
root.right = self
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
end
require "test/unit"
require "avl_tree"
require "red_black_tree"

0 comments on commit a1372ff

Please sign in to comment.