Balanced two-fork tree _ two fork tree

Source: Internet
Author: User

The Balanced binary tree (balanced Binary) is an evolutionary body of two-fork lookup trees and the first two-fork tree to introduce the concept of equilibrium. In the 1962, G.M Adelson-velsky and E.M Landis invented the tree, so it was called an AVL tree. Balanced binary tree requirements for each node, its left and right subtree of the height of the difference can not exceed 1, if the insertion or deletion of a node so that the height difference is greater than 1, it is necessary to rotate between the nodes, the two-fork tree back in a balanced state. This scheme is a good solution to the problem of two-fork lookup tree degradation into a linked list, to insert, find, delete the time complexity of the best and worst-case conditions are maintained in O (Logn). However, frequent rotation causes insertions and deletions to sacrifice O (Logn) time, but the time is much more stable relative to the binary lookup tree.

The balance of binary tree implementation of most of the process and two fork lookup tree is the same (learn to balance the binary tree must be binary lookup tree), the difference is that after inserting and deleting to write a rotation algorithm to maintain balance, maintaining balance requires the use of a node height of the attribute.

Reprint Link Reference link

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.