Ejemplo n.º 1
0
        private AVLNode <T> RotateLeft()
        {
            AVLNode <T> y  = this.Right;
            AVLNode <T> T2 = y.Left;

            // Perform rotation
            y.Left     = this;
            this.Right = T2;

            // Update heights
            this.CalculateHeight();
            y.CalculateHeight();

            // Return new root
            return(y);
        }
Ejemplo n.º 2
0
        private AVLNode <T> RotateRight()
        {
            AVLNode <T> x  = this.Left;
            AVLNode <T> T2 = x.Right;

            // Perform rotation
            x.Right   = this;
            this.Left = T2;

            // Update heights
            this.CalculateHeight();
            x.CalculateHeight();

            // Return new root
            return(x);
        }