全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Balance factor, AVL tree?

又称: balance factor · AVL tree

Definition 17.9 University Computer Science — Year 1 · 第 17 章 — Binary Search Trees and Balanced Trees

The balance factor of a node is the height of its right subtree minus the height of its left subtree. An AVL tree is a binary search tree in which every node has balance factor −1-1, 0 or 1.

Two of the four rebalancing cases, on three keys; the new key is shaded. The node 3 has balance factor -2. When the new key lies left of its left child (LL), one right rotation at 3 restores the balance. When it lies to the right of its left child (LR), a left rotation at 1 turns the case into LL. RR and RL are the mirror images.
Two of the four rebalancing cases, on three keys; the new key is shaded. The node 3 has balance factor −2-2. When the new key lies left of its left child (LL), one right rotation at 3 restores the balance. When it lies to the right of its left child (LR), a left rotation at 1 turns the case into LL. RR and RL are the mirror images.
在原文中阅读 →