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

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