Home > Common Problem > What is a balanced binary tree?

What is a balanced binary tree?

烟雨青岚
Release: 2020-06-29 10:24:37
Original
9690 people have browsed it

The balanced binary tree is a binary tree data structure based on the dichotomy strategy to improve the speed of data search. Use dichotomous thinking to assemble the data into a tree-structured data according to rules. Use this tree-structured data to reduce the retrieval of irrelevant data, which greatly improves the speed of data retrieval.

What is a balanced binary tree?

Concept of balanced binary tree:

The balanced binary tree is a binary tree data structure based on the dichotomy strategy to improve the speed of data search.

Features:

The balanced binary tree uses dichotomous thinking to assemble data into a tree structure according to rules, and uses this tree structure data to reduce the retrieval of irrelevant data. Greatly improves the speed of data retrieval; the data structure assembly process of a balanced binary tree has the following rules:

(1) Non-leaf nodes can only allow up to two child nodes to exist.

(2) The data distribution rule of each non-leaf node is that the child node on the left is smaller than the value of the current node, and the child node on the right is greater than the value of the current node (the value here is based on its own algorithm rules, For example, hash value);

What is a balanced binary tree?

The hierarchical structure of the balanced tree: Because the query performance of the balanced binary tree is inversely proportional to the level of the tree (h height), the smaller the h value, the faster the query. In order to ensure that the data on the left and right ends of the tree structure is roughly balanced and reduce the difficulty of querying the binary tree, an algorithm mechanism is generally used to balance the node data structure. Examples of such algorithms include Treap and red-black trees. The use of balanced binary trees can ensure that the data The difference in node levels on the left and right sides will not be greater than 1. This prevents the tree structure from becoming a linear linked list due to deletions, which affects the query efficiency, and ensures that the speed of data search is close to that of binary search when the data is balanced.

For more related knowledge, please visit PHP Chinese website! !

The above is the detailed content of What is a balanced binary tree?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template