Neocortex 🧠

Search

Search IconIcon to open search

AVL Tree Operations

Last updated Jan 2, 2022 Edit Source

# Insertion

After inserting into an AVL Tree, which works just like a Binary Tree, we insert the node into the tree, we traverse upwards from the inserted node, checking if the AVL property is broken at any point in the tree. If that is the case, we apply trinode restructuring and that is enough to fix the AVL property for this subtree and all the ancestors of that node.

# Deletion

Again, deletion works just like deletion from a BST, once it is done, we again move upwards from the node checking if AVL property is broken, and fix any nodes that break it. In this case, one restructuring is not enough, we need to traverse until the root of the tree.


Interactive Graph