Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Balance factor, AVL tree?

Ook bekend als: balance factor · AVL tree

Definition 17.9 University Computer Science — Year 1 · Hoofdstuk 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.
Lees in het hoofdstuk →