Zodan, right paddle, left and right rotation of AVL tree

Source: Internet
Author: User

Here are the melodrama, with three characters, Root,pivot, and the bottom node.

Photo Citation: https://blog.csdn.net/u012361418/article/details/46535293


According to the order of the three nodes from top to bottom, there are four kinds of cases: the left-left type, right-right type and right-left type, respectively.


1. Left-Left (pivot is the left node of the root node and the bottom node is the left node of pivot)

At this time we make the action to be the right paddle, because it seems to be clockwise rotation, (unified clockwise called the right, counterclockwise called left)

Pivot to the root node says:

I am now your left node;

I want you to do my right node,

This is just my original right node, which is your left node.

Perfect alternative ...

So happy to have finished the adjustment ~

2. Right-right type

At this time, we need to rotate the root node to the left, which is called L;

Pivot to the root says:

I am now your right node,

I want you to be my left node,

So just my original left node, do your right node;

Once again the perfect spin ~

3. Right and left type

Don't be afraid, everyone. Do not escape ~ ~ ~ Because this time finally the bottom node of the play part ... (Touched ....) )

First, the bottom node says to pivot:

I'm your right node,

I want you to be my left node,

So my original left node, just give you right node;

Ha ha...

You know what..

Now it's left and left.

Then the first case of analysis can go on.

Let me just say it here. (After all, this time the original bottom node becomes a new pivot ....) The drama has a sudden spike in wood. )

This time the new pivot (the original bottom node) says to the root node:

I am now your left node,

I want you to be my right node,

So my original right node just happens to be your left node.

This is the perfect place to be an AVL tree.

4. Right-left (right-hand)

The bottom node is right-handed, then the right-right type, the root node left-hand;

This time the bottom node of the play is also more ~

First, the bottom node says to pivot:

I'm your left node,

I want you to be my right node,

So my right node just happens to be your left node;

Then it becomes the right-right type (at which point the bottom node becomes the new pivot)

Then the right-right type of processing, here is left for you to practice it ~ ~



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.