For input, I believe that this is enough.
but for deletion: consider this tree:
50
/ \
25 75
/ \ / \
15 40 60 80
/ / \ \
35 55 65 90
/
62
remove 15, first factor 25 is destroyed, one turn:
50
/ \
35 75
/ \ / \
25 40 60 80
/ \ \
55 65 90
/
62
but, nevertheless, we must check that now the balancing coefficient of the tree root is destroyed, it needs to be rotated again:
60
/ \
50 75
/ \ / \
35 55 65 80
/ \ / \
25 40 62 90
Xueyu source
share