跳到正文

生活·游记

英语题(自创)

ACanaroey约 9 分钟
原文
文章信息与版本

文章信息

发布
2024年10月29日
收录
2026年2月2日
更新
2026年11月15日
篇幅
约 9 分钟

版本

  1. v2当前
  2. v1

Binary Tree

代码
To talk about binary trees, first I need to explain a few basic terms about binary trees.
① Node: Contains a data element and several information pointing to subtree branches .
② The degree of a node: The number of subtrees a node has is called its degree.
③ Leaf nodes: also known as terminal nodes, nodes without subtrees or nodes with zero degrees.
④ Branch node: also known as non terminal node, nodes with non-zero degrees are called non terminal nodes .
⑤ Degree of tree: The maximum degree of all nodes in the tree .
⑥ Node hierarchy: Starting from the root node, assuming that the root node is at level 1 and its child nodes are at level 2, and so on. If a node is at level L, its child nodes are at level L+1 [5].
⑦ The depth of a tree, also known as the height of a tree, is the maximum level of all nodes in the tree.
⑧ Ordered tree: If the order of the sub trees in a tree is sequential, then the tree is called an ordered tree.
⑨ Disordered tree: If the order of the sub trees in a tree is not in chronological order, the tree is called an unordered tree.
A binary tree refers to an ordered tree in which the degree of nodes is not greater than 2, and it is the simplest and most important tree. The recursive definition of a binary tree is: a binary tree is an empty tree, or a non empty tree consisting of a root node and two disjoint left and right subtrees called roots; The left subtree and the right subtree are both binary trees. There are three special cases of binary trees. 1. Full binary tree: If a binary tree has only nodes with degree 0 and degree 2, and the nodes with degree 0 are on the same layer, then the binary tree is a full binary tree.
2. A complete binary tree: A binary tree with n nodes and a depth of k is called a complete binary tree if and only if each node corresponds one-to-one with nodes numbered from 1 to n in a full binary tree with a depth of k. 3. The characteristic of a complete binary tree is that leaf nodes can only appear on the two largest layers of a sequence, and the maximum sequence of descendants under the left branch of a node is equal to or greater than the maximum sequence of descendants under the right branch by 1.
Definition of Recursive Algorithm for Sequential Traverse:
If the binary tree is not empty, perform the following operations in sequence:
⑴ Accessing the root node;
⑵ Traverse the left subtree;
Traverse the right subtree.
2. Definition of recursive algorithm for middle order traversal:
If the binary tree is not empty, perform the following operations in sequence:
⑴ Traverse the left subtree;
⑵ Accessing the root node;
Traverse the right subtree.
3. Definition of recursive algorithm for post traversal:
If the binary tree is not empty, perform the following operations in sequence:
⑴ Traverse the left subtree;
⑵ Traverse the right subtree;
⑶ Access the root node.





Answering


What is the definition of a node in a binary tree?
A. A node contains a data element and several information pointing to subtree branches.
B. A node has a degree that represents the number of subtrees it has.
C. A node is a leaf node if it has no subtrees or zero degrees.
D. A node is a branch node if it has non-zero degrees.

What is the maximum degree of all nodes in a binary tree called?
A. Degree of tree
B. Depth of tree
C. Node hierarchy
D. None of the above

How are the levels of nodes defined in a binary tree?
A. Starting from the root node, each level is one more than the previous level.
B. Starting from the root node, each level is one less than the previous level.
C. Starting from the root node, each level is equal to the previous level plus one.
D. Starting from the root node, each level is equal to the previous level minus one.

What is the characteristic of a complete binary tree?
A. Leaf nodes can only appear on the two largest layers of a sequence.
B. The maximum sequence of descendants under the left branch of a node is equal to or greater than the maximum sequence of descendants under the right branch by 1.
C. All nodes have the same depth.hhhhh
D. All nodes have at least one child.

Given a binary tree, the preorder traversal result is ABDECFG, and the middle order traversal result is DEBACFG. What is the correct post traversal result for this tree?
A. EDBGFCA
B. EDGBFCA
C. DEBGFCA
D. DBEGFCA
原文