Example Code Analysis of web binary Tree
In this article Xiaobian for you to introduce in detail the "web binary tree example code analysis", the content is detailed, the steps are clear, the details are handled properly, I hope this "web binary tree example code analysis" article can help you solve your doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.
Binary tree
The two structures mentioned above (array and linked list) have their own drawbacks.
The 1 "array consumes more resources when it is updated and needs to move the following elements one by one."
2 "and the linked list needs to select the content to be queried after comparing it one by one.
To sum up, we need a structure that queries faster and updates faster, so we have a binary tree.
Features:
Each node has at most two subtrees.
Change 80
Let's take a look at code practice:
Let's get it up and running.
Insert 82
Let's take a look at the code practice (note: add a method insert_bit_tree to the original code):
Let's get it up and running.
The annoyance of binary tree
It is not difficult to find that if you look for some data in a very extreme case, then the situation shown in the above picture will occur. Can you imagine what would happen if there were tens of millions of pieces of data?
For the above reasons, we think of a balanced binary tree, also known as an AVL tree.
Balanced binary Tree: AVL Tree (1962)
Let's look at code practice.
Mainly understand this code.
Diagram the function.
Read here, this "web binary tree example code analysis" article has been introduced, want to master the knowledge of this article also need to practice and use to understand, if you want to know more about the article, welcome to follow the industry information channel.