Bugs: One good thing about them is they keep on inspiring even when you don't want to be.

Saturday, June 13, 2015

AVL Binary Search Tree Implementation in Java

AVL (Adelson-Velsky and Landis) is an example of self-balanced Binary Search Tree. It has the same basic operations as that of a regular BST but modifications are followed by zero or more tree rotation operations. Every node also stores balance factor which is corrected after insertion or deletion. If the recomputed balance factor remains in the range from -1 to +1 then only corrections of the balance factor is required and no rotations are necessary. But if the recomputed balance factor becomes less than -1 or greater than +1 the subtree rooted at this node is unbalanced, and a rotation is needed. The AVLNode class (extends Node from BinarySearchTree class) can be declared like:

3 comments:

Hello bro. I discovered your blog by searching online programming tutorials in Bing Search Engine. This is an extremely well written article. I’ll make sure to bookmark it and return to learn more of your helpful information. Thank you for the post. I’ll definitely comeback.

I have read your blog. Your blog is really helpful for me to know more about Java technology. I did Java Training in Chennai at TIS academy. Its really useful for me to make a bright future in IT industry.