Tree-avl Tree

Source: Internet
Author: User
AVL Tree
The balance tree is most concerned with the prevention of tree imbalance, if a new element crisis to the tree balance, you can immediately correct. You can have a local refactoring tree (AVL method) or rebuild the entire tree (DSW) method.
The AVL tree is a self balanced binary lookup tree in which the maximum difference in height of two subtrees of any node in the AVL tree is one, so it is also known as a highly balanced tree. Additions and deletions may require one or more tree rotations to rebalance the tree.
Balance Factor BF (): Height of the right subtree-Zuozi height
The balance factor of AVL can be 0,1,-1
If a new node is inserted into a balanced binary search tree, it creates an imbalance. At this point, you must adjust the structure of the tree to make it balanced.
Insert operation: Inserts a new node, the associated node state in the AVL tree changes. Therefore, after inserting the new node, you need to backtrack from the insertion position along the Shangen path to check the balance factor of each node.
Delete operation: Set Q is the parent node of the deleted node
If the deletion occurs in the left subtree of Q, then the BF (q) minus 1
If the deletion occurs in the right subtree of Q, then the BF (q) plus 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.