lib/splay_tree.rb
#
# _zig_zig case applied when X is right child of a right child or
#  a left child of a left child
#
# x has a parent and a grand-parent
#
_zig_zig case applied when X is right child of a right child or
a left child of a left child

x has a parent and a grand-parent
_zig_zig case applied when X is right child of a right child or a left child of a left child x has a parent and a grand - parent
def _zig_zig(x, p, gp)
      if gp.rnode == p && p.rnode == x
        puts(" -- right child of a right child")  if $VERBOSE
        _l_rotate(p, gp)
        _l_rotate(x, p)
      else
        puts(" -- left child of a left child")  if $VERBOSE
        _r_rotate(p, gp)
        _r_rotate(x, p)
      end
    end
def _zig_zig ( x , p , gp ) if gp . rnode == p && p . rnode == x puts ( " -- right child of a right child" ) if $VERBOSE _l_rotate ( p , gp ) _l_rotate ( x , p ) else puts ( " -- left child of a left child" ) if $VERBOSE _r_rotate ( p , gp ) _r_rotate ( x , p ) end end
_zig_zig case applied when X is right child of a right child or
a left child of a left child
_zig_zig case applied when X is right child of a right child or a left child of a left child
# right child of a right child # left child of a left child
x
<not_specific>
p
<not_specific>
gp
<not_specific>