VOOZH about

URL: https://www.geeksforgeeks.org/dsa/deletion-in-an-avl-tree/

⇱ Deletion in an AVL Tree - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Deletion in an AVL Tree

Last Updated : 5 Feb, 2026

We have discussed Insertion of AVL Tree. In this post, we will follow a similar approach for deletion.

Steps to follow for deletion
To make sure that the given tree remains AVL after every deletion, we must augment the standard BST delete operation to perform some re-balancing. Following are two basic operations that can be performed to re-balance a BST without violating the BST property (keys(left) < key(root) < keys(right)). 

  1. Left Rotation
  2. Right Rotation
👁 Deletion-in-an-AVL-Tree_
keys(T1) < key(x) < keys(T2) < key(y) < keys(T3)

Example:


Output
Preorder traversal of the constructed AVL tree is 
9 1 0 -1 5 2 6 10 11 
Preorder traversal after deletion of 10 
1 0 -1 9 5 2 6 11 

Time Complexity: The rotation operations (left and right rotate) take constant time as only few pointers are being changed there. Updating the height and getting the balance factor also take constant time. So the time complexity of AVL delete remains same as BST delete which is O(h) where h is height of the tree. Since AVL tree is balanced, the height is O(log n). So time complexity of AVL delete is O(log n). 
Auxiliary Space: O(log n) for recursion call stack as we have written a recursive method to delete

Summary of Deletion in AVL Trees:

  • Deletion in AVL trees is similar to deletion in a Binary Search Tree (BST), but followed by rebalancing operations.
  • After deleting a node, the balance factor of ancestor nodes may change.
  • If the balance factor goes outside the range of -1 to +1, rotations (LL, RR, LR, RL) are required to restore balance.
  • The type of rotation depends on the balance factors of the affected node and its children.
  • Time complexity of deletion remains O(log n) due to the balanced nature of the tree.
Comment