Try the idea of verbal expression traversing the binary tree according to the hierarchy.

Updated on technology 2024-06-07
3 answers
  1. Anonymous users2024-02-11

    Traversal of the binary tree:

    1. Pre-order traversal (DLR), which first visits the root node, then traverses the left subtree, and finally traverses the right subtree.

    2. Intermediate order traversal (LDR), first traversing the left subtree, then visiting the root node, and finally traversing the right subtree.

    3. Post-Order Traversal (LRD) first traverses the left subtree, then visits the traversal of the right subtree, and finally visits the root node.

    A binary tree is an ordered tree in which the degree of nodes in the tree 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 composed of a root node and two disjoint left and right subtrees called roots, respectively; Both the left and right subtrees are also binary trees.

    Binary tree nature

    Property 1: There are at most 2i-1(i 1) nodes on the ith level of the binary tree.

    Property 2: A binary tree with depth h contains up to 2h-1 nodes.

    Property 3: If there are n0 leaf nodes and n2 nodes of degree 2 in any binary tree, then there must be n0=n2+1.

    Property 4: A full binary tree with n nodes is log2n+1 deep.

    Property 5: If a complete binary tree with n nodes is sequentially numbered (1 i n), then, for nodes numbered i(i 1):

    When i=1, the node is the root, and it has no parental node.

    When i>1, the number of the parent node of that node is i2.

    If 2i n, then there is a left node numbered 2i, otherwise there is no left node.

    If 2i+1 n, there is a right node numbered 2i+1, otherwise there is no right node.

  2. Anonymous users2024-02-10

    1 All1 A binary tree with only an empty binary tree and a binary tree with one root node have exactly the same order of intermediate and post-order traversals.

    This is false, if all the nodes of a binary tree have no right children, the order of the intermediate and posterior traversal is exactly the same.

    2.All binary trees with empty left subtrees have exactly the same order of intermediate and post-order traversal order.

    This statement is false, for reasons 1

    3. If the right subtree of all nodes is empty, the middle and back order of the binary tree are exactly the same.

    This one is correct.

    4 There is a non-empty binary tree with the same pre-order, middle-order, and post-order traversals.

    This is true, for example, a binary tree with only root nodes has the same pre-order, middle-order, and post-order traversals.

  3. Anonymous users2024-02-09

    Root-first or first-order traversal: The root node is visited first, then the left subtree, and finally the right subtree.

    Middle root traversal or middle order traversal: Traverses the left subtree first, then the root node, and finally the right subtree.

    Post-root traversal or post-order traversal: first traverses the left subtree, then the right subtree, and finally visits the root node.

    Traversal by hierarchy or width priority, starting with the root node, accessing each layer node from top to bottom, and within the same layer node, accessing each node from left to right.

Related questions
10 answers2024-06-07

Is this the text expression that the landlord said? (Reflected conditions in parentheses) 1Magnesium + oxygen = (ignited) magnesium oxide. >>>More

14 answers2024-06-07

No matter what input method you use, press Ctrl+Period to switch to; >>>More

8 answers2024-06-07

Plagiarized text means that if you quote someone else's text without indicating the source, the system will automatically retrieve it, and when a certain number of the same text appears, it will be considered that there is plagiarized text. Describe it in your own words, and this phenomenon is not easy to occur. >>>More

11 answers2024-06-07

The most beautiful theme song of love "Visible Happiness". >>>More

11 answers2024-06-07

Spring is vibrant, cheerful and jumping, and bright and moving. In the author's pen, I saw a more ancient and beautiful spring. >>>More