Do you feel that the tree in the data structure of the big line, what areas should be stained with a touch.
Take us a few days ago to learn the sort used to the heap and today said "binary sorting tree", so Extreme said, master of the tree you are cattle.
Today we'll talk about the last "binary sort Tree" in the "Five Classics" search.
1. Concept:
<1> is actually very simple, if the root node has a Zoozi tree, then all nodes of the left subtree are smaller than the root node.
If the root node has a right subtree, all nodes of the right subtree are larger than the root node.
The <2> diagram is a "binary sort Tree", which is then compared against the concept of a comparison.
2. Actual operation:
We all know that a thing to operate, nothing more than to check and change, then we will talk about the basic operation.
<1> Insert: I believe that the concept of "sorted tree" is clear, then the principle of insertion is very simple.
Let's say we insert a 20 into this tree.
First: 20 compared with 50, found that 20 is the youngest, the last resort, to be summed up to 50 of the left subtree to compare.
Then: 20 compared with 30, found that 20 or the youngest.
Then: 20 compared to 10, found himself the eldest, and then inserted into the 10 right subtree.
Finally: The effect rendering diagram is as follows: