one (single topic) There is a "genetic" relationship: let X be the father of Y, then x can inherit its attributes to y. The most suitable data structure for this genetic relationship is ()
two (single topic) Trees are best used to represent ().
A ordered data elements
Data with branch hierarchical relationship between B elements
C unordered data elements
Data with no connection between D elements
three (single topic) The nodes of the binary tree are numbered continuously from 1. The number of each node is required to be greater than the number of its left and right children. Among the left and right children of the same node, the number of its left child is less than its right child, then the traversal of () order can be used to realize the node number of the binary tree.
B middle order
C post sequence
D traverses hierarchically from the root
four (single topic) Assuming that the number of nodes of a trident tree is 50, its minimum height is ().
Set the root node level to 1 Layer 1: 1 node The second layer has at most 3 nodes The third layer has at most 9 nodes The fourth layer has 27 nodes The fifth layer has a maximum of 81 nodes 1 + 3 + 9 + 27 = 40 < 50 1 + 3 + 9 + 27 + 81 = 121 > 50 So there are at least five floors
five (single topic) In a full Trident tree with K layers, the total number of nodes is ()
Full binary tree nodes n =1+3+3^2+...+3^(k-1)=(3^k-1)/2
six (single topic) According to the definition of binary tree, there are () kinds of binary trees with three nodes.
seven (single topic) For a full binary tree, m leaves, n nodes, depth h, then ().
eight (single topic) In a binary tree, the maximum number of nodes in the fifth layer is () (assuming that the number of layers of the root node is 0)
When it is a full binary tree, the maximum number of nodes in the fifth layer is 2^5=32 (The number of root node layers is required to be 0)
9. (single topic) A binary tree with a depth of 5 has at most () nodes.
When it is a full binary tree, the maximum number of total nodes is 1+2^1+2^2+2^3+2^4=2^5-1=31
ten (single topic) A complete binary tree with 124 leaf nodes has () nodes at most.
Complete binary tree has the following properties: n=n0+n1+n2 n0=n2+1 n:Total number of nodes n0:The number of nodes with degree 0, that is, leaf nodes n1:The number of nodes with degree 1 has two cases: 0 and 1 in the median of a complete binary tree n2:Number of nodes with degree 2 because n0=124 therefore n2=123 n1=0 Or 1(The maximum number of nodes to be, n1 Take 1) n=n0+n1+n2=124+1+123=248
eleven (single topic) A complete binary tree with 129 leaf nodes has at least () nodes.
Complete binary tree has the following properties: n=n0+n1+n2 n0=n2+1 n:Total number of nodes n0:The number of nodes with degree 0, that is, leaf nodes n1:The number of nodes with degree 1 has two cases: 0 and 1 in the median of a complete binary tree n2:Number of nodes with degree 2 because n0=129 therefore n2=128 n1=0 Or 1(To minimize the number of nodes, n1 Take 0) n=n0+n1+n2=129+0+128=257
12. (single topic) Suppose that in a binary tree, the number of double branch nodes is 15 and the number of single branch nodes is 30, then the number of leaf nodes is ().
n0=n2+1 It is proved that let the number of leaf nodes on the binary tree be n0，The number of single branch nodes is n1，The number of double branch nodes is n2，Total number of nodes n=n0+n1+n2. In a binary tree, the number of branches (i.e. degrees) of all nodes should be equal to the number of single branch nodes plus twice the number of double branch nodes, i.e. the total number of branches=n1+2n2. Because each node in the binary tree has a unique branch pointing to it except the root node, there are: the total number of branches in the binary tree=Total nodes-1. From the above three equations: n1+2n2=n0+n1+n2-1 Namely: n0=n2+1
thirteen (single topic) All nodes in the complete binary tree are stored in the array R[1..n] layer by layer by sequential storage method. If the node R[i] has a left subtree, the left subtree is a node ()
fourteen (single topic) In the middle order traversal sequence of a non empty binary tree, the right side of the root node ().
A has only all nodes on the right subtree
B has only some nodes on the right subtree
C has only some nodes on the left subtree
D has only all nodes on the left subtree
The middle order traversal order is: left root right To the right of the root node are all the nodes in the right subtree
fifteen (single topic) The relative order of leaf nodes of any binary tree in preorder, inorder and postorder traversal ().
A no change
C not sure
D none of the above is true
Leaf nodes are nodes without left and right subtrees. Without left and right subtrees, leaf nodes cannot be roots. The traversal order of first order, middle order and second order is the change of root position. Therefore, the relative order of leaf nodes in first order, middle order and second order traversal does not change.
sixteen (single topic) Let N and m be two nodes on a tree. When traversing in middle order, the condition before n is m is ().
An is to the right of m
Bn is the ancestor of m
Cn to the left of m
Dn is the descendant of m
seventeen (single topic) It is known that the post order traversal sequence of a binary tree is dabec, the middle order traversal sequence is debac, and its pre order traversal sequence is ().
eighteen (single topic) If the binary tree uses the binary linked list as the storage structure, it is most appropriate to use the () traversal method to exchange the positions of the left and right subtrees of all its branch nodes.
B middle order
C post sequence
Use the binary linked list storage structure, that is, the storage structure of the left child and the right brother. Post order traversal is reasonable. The normal logic should be: do a good job in the internal exchange of the current node subtree, and then exchange the left and right subtrees of the current node. It just conforms to the algorithm logic of post order traversal. 1,Swap left subtree 2,Swap right subtree 3,Swap left subtree and right subtree Other algorithms, such as preorder and hierarchy, have similar logic, that is, exchange their left and right subtrees when accessing the current node. Logically, it's a little awkward. Therefore, the most appropriate is post order traversal, but in terms of implementation, pre order and hierarchy are OK. 1,Swap left subtree and right subtree 2,Traverse left subtree 3,Traversing right subtree Traversal by hierarchy 1,Root node in queue 2,Out of the queue, exchange its left and right subtrees, and put the root of the subtree into the queue 3,Repeat 2 until the queue is empty Middle order traversal is relatively difficult to implement.
nineteen (single topic) In order to realize the non recursive algorithm of post order traversal of any binary tree without using stack structure, the best scheme is that the binary tree adopts () storage structure.
A trigeminal linked list
B generalized table
C binary linked list