Permalink
Browse files

Fix reversed name (rotation)

  • Loading branch information...
nahi committed Feb 5, 2012
1 parent 4154dd4 commit a1372ffe2305886cc71ed5d4569a31778cae1fc3
Showing with 7 additions and 6 deletions.
  1. +6 −6 lib/avl_tree.rb
  2. +1 −0 test/helper.rb
View
@@ -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
@@ -238,7 +238,7 @@ def rotate
# / \ / \
# c E a c
#
- def rotate_right
+ def rotate_left
root = @right
@right = root.left
root.left = self
@@ -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
View
@@ -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.