Create binary trees, layer order, and middle order traversal in the Pascal language

Updated on technology 2024-02-09
9 answers
  1. Anonymous users2024-02-05

    It is strongly recommended that the landlord make the topic clear, including how to input and what the output format is.

  2. Anonymous users2024-02-04

    The node sequences traversed by the pre-order are: befcgdh; The node sequences traversed by the middle order are: febgchd; The sequence of nodes traversed in the post-order is: feghdcb.

    The pre-order traversal first visits the root node, then traverses the left subtree, and finally traverses the right subtree; The order traversal first traverses the left subtree, then visits the root node, and finally traverses the right subtree; The sequential traversal is first left, then right, and then root, i.e., the left subtree is traversed first, then the right subtree, and finally the root node is visited.

  3. Anonymous users2024-02-03

    Pre-order traversal of fdbacegihj

    The middle order traverses abcdefhijg

    Subsequent traversal of Acbedhjigf

  4. Anonymous users2024-02-02

    <> the first number as the root node, divide the next number into those larger than 30 and smaller than 30, the small number is placed on the left, the large number is placed on the right, and then in the order in which the numbers appear, one by one, the larger than the root node is placed on the right, and the small one is placed on the left.

  5. Anonymous users2024-02-01

    30 below left, 15 right, 43

    15 below left, 8 right, 25

    43 below right 49

    8 below right 13

    25 below left, 20 right, 28

    49 below left, 46 right, 55

    13 below the left 10

  6. Anonymous users2024-01-31

    First of all, understand the general idea:

    Pre-order traversal: The operation to access the root node occurs before traversing its left and right subtrees.

    Middle-order traversal: The operation of accessing the root node occurs in the traversal of its left and right subtrees.

    Post-order traversal: The operation of accessing the root node occurs after traversing its left and right subtrees.

    eg: The post-order traversal is dbcefgha, the middle-order traversal is edcbahfg, and the pre-order traversal is found (online example).

    Solution: First, look at the post-order traversal dbcefgha, a is the total root node, and then find the middle order traversal the position of a in edcbahfg, then edcb is on the left branch of a, and hfg is on the right branch of a;

    Repeat the first two steps, traversing the last digit from the back order to find the corresponding point, and traversing the middle order to find the corresponding point, and get the left and right branches.

    Finally, get aecdbhgf, and then verify it yourself.

  7. Anonymous users2024-01-30

    The last letter of the subsequent iteration is bifurcation bai

    tree "roots"; du

    The first of the pre-order traversal.

    The letter zhi is the binary forked dao tree "root"; e/

    d b\c/a

  8. Anonymous users2024-01-29

    The sequence is traversed according to the number of layers, first at the top layer, then at the second layer, then at the third layer...

  9. Anonymous users2024-01-28

    Answer]: b Binary sorting tree, also known as binary search staring tree, it is either an empty tree, or it is called a binary tree with the following Kai cherry properties: if its left subtree is not empty, the value of all nodes on the left subtree is less than the value of the root node; If its right subtree is not empty, the value of all nodes on the right subtree is greater than the value of the root node.

    Based on these two properties of a binary sort tree, if the sequence obtained by traversing it in order is an ordered sequence, option b is correct.

Related questions
11 answers2024-02-09

First of all, it is necessary to understand what a binary tree is (and I guess the subject also understands). >>>More