This commit is contained in:
krahets
2024-07-30 16:54:47 +08:00
parent 8fb4fdc14c
commit 55b91eb967
140 changed files with 426 additions and 1278 deletions
+14 -14
View File
@@ -1752,18 +1752,18 @@
</li>
<li class="md-nav__item">
<a href="#3-right-left-rotation" class="md-nav__link">
<a href="#3-left-right-rotation" class="md-nav__link">
<span class="md-ellipsis">
3. &nbsp; Right-left rotation
3. &nbsp; Left-right rotation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#4-left-right-rotation" class="md-nav__link">
<a href="#4-right-left-rotation" class="md-nav__link">
<span class="md-ellipsis">
4. &nbsp; Left-right rotation
4. &nbsp; Right-left rotation
</span>
</a>
@@ -3724,18 +3724,18 @@
</li>
<li class="md-nav__item">
<a href="#3-right-left-rotation" class="md-nav__link">
<a href="#3-left-right-rotation" class="md-nav__link">
<span class="md-ellipsis">
3. &nbsp; Right-left rotation
3. &nbsp; Left-right rotation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#4-left-right-rotation" class="md-nav__link">
<a href="#4-right-left-rotation" class="md-nav__link">
<span class="md-ellipsis">
4. &nbsp; Left-right rotation
4. &nbsp; Right-left rotation
</span>
</a>
@@ -4463,15 +4463,15 @@
</div>
</div>
</div>
<h3 id="3-right-left-rotation">3. &nbsp; Right-left rotation<a class="headerlink" href="#3-right-left-rotation" title="Permanent link">&para;</a></h3>
<h3 id="3-left-right-rotation">3. &nbsp; Left-right rotation<a class="headerlink" href="#3-left-right-rotation" title="Permanent link">&para;</a></h3>
<p>For the unbalanced node 3 shown in Figure 7-30, using either left or right rotation alone cannot restore balance to the subtree. In this case, a "left rotation" needs to be performed on <code>child</code> first, followed by a "right rotation" on <code>node</code>.</p>
<p><a class="glightbox" href="../avl_tree.assets/avltree_left_right_rotate.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Right-left rotation" class="animation-figure" src="../avl_tree.assets/avltree_left_right_rotate.png" /></a></p>
<p align="center"> Figure 7-30 &nbsp; Right-left rotation </p>
<p><a class="glightbox" href="../avl_tree.assets/avltree_left_right_rotate.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Left-right rotation" class="animation-figure" src="../avl_tree.assets/avltree_left_right_rotate.png" /></a></p>
<p align="center"> Figure 7-30 &nbsp; Left-right rotation </p>
<h3 id="4-left-right-rotation">4. &nbsp; Left-right rotation<a class="headerlink" href="#4-left-right-rotation" title="Permanent link">&para;</a></h3>
<h3 id="4-right-left-rotation">4. &nbsp; Right-left rotation<a class="headerlink" href="#4-right-left-rotation" title="Permanent link">&para;</a></h3>
<p>As shown in Figure 7-31, for the mirror case of the above unbalanced binary tree, a "right rotation" needs to be performed on <code>child</code> first, followed by a "left rotation" on <code>node</code>.</p>
<p><a class="glightbox" href="../avl_tree.assets/avltree_right_left_rotate.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Left-right rotation" class="animation-figure" src="../avl_tree.assets/avltree_right_left_rotate.png" /></a></p>
<p align="center"> Figure 7-31 &nbsp; Left-right rotation </p>
<p><a class="glightbox" href="../avl_tree.assets/avltree_right_left_rotate.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Right-left rotation" class="animation-figure" src="../avl_tree.assets/avltree_right_left_rotate.png" /></a></p>
<p align="center"> Figure 7-31 &nbsp; Right-left rotation </p>
<h3 id="5-choice-of-rotation">5. &nbsp; Choice of rotation<a class="headerlink" href="#5-choice-of-rotation" title="Permanent link">&para;</a></h3>
<p>The four kinds of imbalances shown in Figure 7-32 correspond to the cases described above, respectively requiring right rotation, left-right rotation, right-left rotation, and left rotation.</p>