DSA-II UNIT II_ AVL TREE Introduction
DSA-II UNIT II_ AVL TREE Introduction
UNIT-II
AVL Tree
WHY AVL TREE?
🞆 What if the input to binary search tree comes
in a sorted (ascending or descending)
manner? It will then look like this
AVL TREE
🞆 AVL tree is a binary search tree in which the
difference of heights of left and right subtrees
of any node is less than or equal to one.
🞆 The technique of balancing the height of
binary trees was developed by Adelson,
Velskii, and Landi and hence given the short
form as AVL tree or Balanced Binary Tree.
🞆 The Balance factor of a node in a binary tree
can have value 1, -1, 0, depending on whether
the height of its left subtree is greater, less
than or equal to the height of the right
subtree.
AN AVL TREE CAN BE DEFINED AS
FOLLOWS:
🞆 Let T be a non-empty binary tree with TL and
TR as its left and right subtrees. The tree is
height balanced if:
🞆 TL and TR are height balanced
🞆 hL - hR <= 1, where hL - hR are the heights of
TL and TR