Data structure and algorithm analysis-C language description version Mark Allen Weiss

Source: Internet
Author: User

Indicates that the results of the keyword 3,9,1,5 in the stretch tree in Figure 4-61 are accessed sequentially.


Figure 4-61


1. Principle


There are two main ways of rotation:

1) rotation of the sub-type

2) one-font rotation

The two approaches are actually a little different:

The sub-type rotation is a combination of two single rotations, and can be seen as the selection of the parent node of the target node (the following example illustrates)

The rotation of the grandparent node of the target node is followed by the rotation of the parent node (described in the following example).

Therefore, the standard AVL double rotation referred to in the book can be decomposed into two steps.


2. Exercise rotation steps:

1) 3-node access

First step: Node 3-2-4 Zigzag: Parent node rotation, so 2-1 rotation



The second step: this cannot be seen here as a 3-4-101 byte point, since the standard AVL rotation is rotated to two, so the second step of the previous 3-2-4 glyph is performed:

The 3 node's parent node 4 rotates.



The third step: only 3-10 nodes at this time, just rotate the parent node directly




2) 9-node access

First step: Connect the 9-8-61 font, after the standard AVL rotation:



Step Two: 9-4-10 zigzag standard AVL after rotation



The third step: only the parent node, no grandfather, the direct rotation of the parent node can be



3) 1-node access

First step: 1-2-31 font, after standard AVL rotation



Step Two: 1-9 only parent node, rotate parent node directly



4) 5-node access

First step: 5-6-81 glyphs, after dimensioning AVL rotation:



Step Two: 5-4-31 font, standard AVL after rotation



Step three: 5-2-9 zigzag, after standard AVL rotation:



Fourth step: 5-1, only the parent node




Data structure and algorithm analysis-C language description version Mark Allen Weiss

Related Article

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.