First binary sequence configuration && binary sort tree, in sequence, after traversing the tree parentheses indicates the rule &&

First, the sequence 685793 construct binary sort tree:

 

Binary sort tree traversal sequence after that is orderly;

Binary sort tree structure following steps;

Insert construction method:

 

 2、

 

 

 

 

 

 

So the node to be inserted to begin comparing the root, the root node than the other hand subtree large to enter into the left and right subtree;

In the above sub-tree with the left (right subtree) into the junction point of comparison method;

Until no node in the insertion; you give the final sorted binary sort tree as follows;

 

 

 Inorder traversal result: 3,456,789;

 Preorder result: 6,435,879;

After establishing lookup binary sort tree, the search is successful and so the probability that the average length of (1 + 2 + 4 * 3 * 2) / 7 = 17/7

example:

Known as the length of the table 16,3,7,11,9,26,18,14,15 9, to find after the establishment of binary sort tree, then wait for the next case to find the probability of success of the average search length (31/9 )

Find This title examines the binary sort tree.
Binary sort tree is also known as a binary search tree, which is defined as: binary sort tree or an empty tree or a binary tree having the following properties (BST property):
(1) if it is not empty left subtree , the value of the left sub-tree, all the nodes are less than the root node;
(2) if it is non-empty right subtree, the right subtree of the values of all the nodes are greater than the root node;
(3) left, each right subtree itself is a binary sort tree.
In doing this problem, first table into nine elements constitute a binary tree binary sort tree, when constructing a binary sort tree, we turn to the table of elements constructed in accordance with the rules of binary sort tree to tree additive elements, after obtaining binary sort tree, computing the average length is simplified as (1 + 2 + 3 + 2 + 3 + 4 + 5 + 5 + 6) / 9 = 31/9.

 

Second, the first order of the binary tree, in sequence, after traversal

Preorder traversal: root -> left subtree -> right subtree (Root -> Left -> right)

中序遍历:左子树->根节点->右子树(左->根->右)

后序遍历:左子树->右子树->根节点(左->右->根)

 

举个例子

 

 

前序遍历:根结点 —> 左子树 —> 右子树(先遍历根节点,然后左右)

这棵树的前序遍历为:ABDEGHCF

中序遍历:左子树—> 根结点 —> 右子树(在中间遍历根节点)

这棵树的中序遍历为:DBGEHACF

后序遍历:左子树 —> 右子树 —> 根结点(最后遍历根节点)

这棵树的后序遍历为:DGHEBFCA
 
 
三、树的括号表示规则

(1)若树T为空树,则其括号表示为空

(2)若树T只包含一个结点,则其括号表示即为该结点本身

(3)若树T由根结点A和它的m棵子树T1,T2,...,Tm构成,则其括号表示为:A(T1的括号表示,T2的括号表示,... ,Tm的括号表示)

其中,子树的括号表示同样应该遵循以上规则

 

实例:

 

 

 
四、知道先序中序求后序
 

 

 

 

 

Guess you like

Origin www.cnblogs.com/kongbursi-2292702937/p/12003352.html