mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
975 B
975 B
| title | aliases | tags | |
|---|---|---|---|
| balancing-binary-search-trees | Balancing BST, balancing |
|
the height of a BST is the length of its longest chain. Most operations are O(n) where n is the height of the tree. In an Ideal situation each layer of the tree is full. The height of the tree is logarithmic to the number of nodes.
When a tree is being used only occainsonally, we can afford to simply rebalance is periodically. However when it is in constant use we cannot afford this cost
Rotations
sometimes two rotations are needed
When to rotate and how to do them
basic idea is to modify the add and delete operations fo the BST to be somewhat self-balancing. This does not need to be perfect
We need a rule to decide when the tree is "balanced enough" and also strategies for fixing problems when the rule is violated.
We only need to fix the area local to the add or delete operations