mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-13 20:20:58 +00:00
build
This commit is contained in:
@@ -767,21 +767,21 @@ It can be observed that **the right and left rotation operations are logically s
|
||||
[class]{AVLTree}-[func]{leftRotate}
|
||||
```
|
||||
|
||||
### 3. Right-left rotation
|
||||
### 3. Left-right rotation
|
||||
|
||||
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 `child` first, followed by a "right rotation" on `node`.
|
||||
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 7-30 Right-left rotation </p>
|
||||
<p align="center"> Figure 7-30 Left-right rotation </p>
|
||||
|
||||
### 4. Left-right rotation
|
||||
### 4. Right-left rotation
|
||||
|
||||
As shown in Figure 7-31, for the mirror case of the above unbalanced binary tree, a "right rotation" needs to be performed on `child` first, followed by a "left rotation" on `node`.
|
||||
|
||||
{ class="animation-figure" }
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> Figure 7-31 Left-right rotation </p>
|
||||
<p align="center"> Figure 7-31 Right-left rotation </p>
|
||||
|
||||
### 5. Choice of rotation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user