Can anyone tell me the pros and cons of the three traversals of a binary tree?

Updated on technology 2024-02-24
6 answers
  1. Anonymous users2024-02-06

    Complete**, the global variable outstr contains the traversal result.

    It's OK to run, but there's a problem, how do you display the data stored in the stack every time the stack changes?

    pnode (You can't use it that way.)

    uses

    type.

    pnodenode;

    noderecord

    datastring;

    lchild,rchild

    pnode;

    end;procedure

    inorder(p:

    pnode);

    vars:tstack;

    begins:=;

    dobegin

    nildobegin

    end;p:=;

    thenbegin

    p:=;strout:=strout+p^.data+##

    end;end;

    end;

  2. Anonymous users2024-02-05

    The access path is the same for the three algorithms. It's just that the timing of accessing the node is different.

    First. Minor menstruation.

    Outdated access is.

    Pre-order traversal. The second passing time visit was.

    Middle-order traversal. The third passing time visit was.

    Post-order traversal. Quote the conclusion of the Internet.

    I feel that there are no shortcomings in the three, and there are good points. It's just that a specific algorithm is used according to the specific needs.

  3. Anonymous users2024-02-04

    Search for "C implements binary trees (modular integration, recursive and non-recursive implementations of traversal)", which is a blog post in the blog park, which is more comprehensive about the recursive and non-recursive algorithms for the front, middle and back layers of binary trees.

  4. Anonymous users2024-02-03

    I just learned the binary tree, if there is any mistake, please correct.

  5. Anonymous users2024-02-02

    You can understand it this way:

    Nodes: Refers to the points in the binary tree, which are the ones in the figure below;

    Degree: Refers to how many child nodes there are under the parent node, give two examples and you will understand. For junction 1, he has two children below, so the degree of junction 1 is trembling chakra 2; For junction 4, he doesn't have any children below, so the degree of junction 4 is 0;

    Placing it in traversal is a little cumbersome, but to grasp the following points on it (no matter what big or small the tree is):

    Forerunner: The root node is the first to visit, then the left and right children are visited;

    Sequence: The root node is visited last, and the left and right children are interviewed first;

    Middle order: The second visit to the root node, the left child is visited first, and the right child is visited last.

    The following picture is an example: I will write the answer to you, and you will study it yourself

    Pre-sequence: 0134256

    Later Lease Sequence: 3415620

    Intermediate sequence: 3140526

  6. Anonymous users2024-02-01

    Traversal Rules:

    Post-order traversal, left-right-root dbe fcg a mid-order traversal, left-root-right dbe a fcg pre-order traversal, root-left-right a dbe fcg

Related questions
9 answers2024-02-24

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

4 answers2024-02-24

Feelings can't be forced, in fact, I think you should analyze the main problem of your breakup at that time, why wait, mainly depends on you, do you think your relationship is worth keeping, do you want to keep, or whether it is necessary to keep. If you feel that you still care about the relationship between you, you can try to change it, make up for the mistakes of the past together, let go of the stones in your heart, and feel the good times you used to have again. If you feel that he doesn't care about the relationship anymore and doesn't matter in your heart anymore, then don't force it too much.

3 answers2024-02-24

Title: Songs from a Secret Garden.

The first album released by the world-famous band Secret Garden, Songs from a Secret Garden >>>More

8 answers2024-02-24

It is an obscure type, but it is already the absolute main force of Valencia and the national team, and when he was young, he was rejected by Real Madrid on the grounds of being thin.

22 answers2024-02-24

A friend is that even if you are not in the same place, you don't need to think about it all the time, you don't need to keep in touch with each other, occasionally you have troubles to call him, he will listen to you, he won't think you're annoying, and he won't talk to you in an impatient tone, when you have difficulties, he will help you without saying a word, he will help you get ahead, and he will feel very warm when he is with him.