Tous les livres

Professionnel

Applis À propos Coach Connexion Commencer la lecture

Computer Science · Glossaire

Qu'est-ce que « Balance factor, AVL tree » ?

Aussi appelé : balance factor · AVL tree

Definition 17.9 University Computer Science — Year 1 · Chapitre 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.
Lire dans le chapitre →