Fix right-left and left-right inversion on AVL Binary Tree
This commit is contained in:
parent
2758e06374
commit
a33a439f15
@ -291,16 +291,16 @@ It can be observed that **the right and left rotation operations are logically s
|
||||
|
||||
### Right-left rotation
|
||||
|
||||
For the unbalanced node 3 shown in the figure below, 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`.
|
||||
|
||||

|
||||
|
||||
### Left-right rotation
|
||||
|
||||
As shown in the figure below, 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`.
|
||||
|
||||

|
||||
|
||||
### Left-right rotation
|
||||
|
||||
For the unbalanced node 3 shown in the figure below, 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`.
|
||||
|
||||

|
||||
|
||||
### Choice of rotation
|
||||
|
||||
The four kinds of imbalances shown in the figure below correspond to the cases described above, respectively requiring right rotation, left-right rotation, right-left rotation, and left rotation.
|
||||
|
Loading…
Reference in New Issue
Block a user