Khác biệt giữa bản sửa đổi của “Cây AVL”
Nội dung được xóa Nội dung được thêm vào
n →Tham khảo: General Fixes |
Không có tóm lược sửa đổi |
||
Dòng 56:
CALCULATE-BALANCE(u)
// Tính hệ số cân bằng và chiều cao cây con tại đỉnh u.
if u.right = Null and u.left=Null then
begin height(u)=1; balance(u)=0 end; else
end
begin height(u)=height(u.right)+1; balance(u)=-height(u) end;▼
else
else begin height(u)=max(height(u.left),height(u.right))+1;▼
if u.left = Null and
begin
balance(u)=-height(u)
end;
else
begin
balance(u)=height(u.left)-height(u.right);
end;
REBALANCE(v)
Hàng 79 ⟶ 92:
end;
if balance(u)>2 then
if balance(u.left)>0 then
RIGHT-ROTATE(u) else
else begin LEFT-ROTATE(u.left); RIGHT-ROTATE(u); end;▼
begin
RIGHT-ROTATE(u);
end;
else
if
if balance(u.right)< 0 then
LEFT-ROTATE(u) else
begin
RIGHT-ROTATE(u.right);
LEFT-ROTATE(u);
end;
==Phép xóa trên cây AVL==
|