From the course: Python Data Structures: Trees

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Smarter automated rebalancing

Solution: Smarter automated rebalancing - Python Tutorial

From the course: Python Data Structures: Trees

Start my 1-month free trial

Solution: Smarter automated rebalancing

(upbeat music) - [Instructor] So if you've finished this challenge successfully then congratulations are in order because you have just invented the self-balancing tree. In all seriousness, many of the techniques we've used throughout this series to balance these binary search trees come from the AVL Tree named for the Soviet Mathematician slash Computer Scientists Adelson Velsky and Landis who first came up with them in 1962. So the AVL Tree's known as a self-balancing tree that it's able to correct or rebalance itself after every insertion or deletion and it does this in a really efficient way. So figuring out which nodes to check and rotate after an insertion or deletion is really one of the last fundamental pieces to making these trees work. So the trick here is that under both insertion and deletion you only need to check the balance of the nodes on the path from the node that you inserted or…

Contents