C, how to create a binary tree after string truncation is described in detail in the question supple

Updated on technology 2024-02-08
11 answers
  1. Anonymous users2024-02-05

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

    A binary tree is a structure in which each node has a maximum of two subtrees (nonsense), and the root node of each subtree also satisfies this property (i.e. the binary tree is defined recursively) and starts now. Start by defining the structure.

    struct nodee}d} subtree.

    ab root node left subtree right subtree.

    e} d Left subtree Right subtree.

    That is, the first treatment can be divided into three parts: the root, the left subtree, and the right subtree.

    After that, it can be divided into two parts at a time: the left subtree, the right subtree.

    Assume that the basic format is node B within the root node AC

    Apparently recursive analysis is possible, and then it's good to go!

    void vis(node* n);

    char wr[20]="ae}d}b";Read in the string.

    int length=11;String length.

    node* l;Root pointer.

    int main(){

    node na;Create a root node.

    l=&na;;;

    build(2,length-3,;Create a left subtree.

    build(length-1,length-1,;Create a right subtree.

    vis(l);Traverse the binary tree.

    return 0;

    void vis(node* n)

    if(!n) return;

    for(int i=n->s;in+n->s;i++)coutvis(n->r);

    Parsing string, start position, end position, parent node pointer.

    if(st>en)return;

    nod=(struct node *)malloc(sizeof(struct node));

    nod->s=st;

    nod->n=en-st+1;

    nod->l=0;

    nod->r=0;

    if(st==en)return;

    build(st+1,en-2,nod->l);

    build(en,en,nod->r);

  2. Anonymous users2024-02-04

    If you understand the binary tree, then the problem is just to be done.

  3. Anonymous users2024-02-03

    Defines the type of the binary tree structure data element and the data structure cbttype of the binary tree structure. The specific data of the node is stored in a sister data, while the pointer left is used to point to the left subtree node, and the pointer right is used to point to the right subtree node.

  4. Anonymous users2024-02-02

    Pls are you going to build a b-tree?? You can say what tree you want to build, and then the tree node type (char...).Then there is the purpose you want to achieve, so it is better to help you see**. Thank you.

  5. Anonymous users2024-02-01

    If I were going to deal with a tree structure like this, I would do it.

    1. In the case that the amount of data is not very large, the node is less than 10,000.

    2. Think of the n-fork tree as a complete n-fork tree.

    3. Write to the file in the form of layer traversal.

    4. When it is read out, it is also built by layer traversal to build an n fork tree.

    Special handling: 1. For the point where the subtree is empty, it is also written to the file according to the size of a node space.

    2. When reading the file, because the size of the node is the same, you can randomly locate a certain node and read the information of the node.

  6. Anonymous users2024-01-31

    You can use fstream for file import and export archive usage.

  7. Anonymous users2024-01-30

    Changed to a false one.

    In this way, the modification to t can be reflected outside the positive branch function and the sensitive number.

  8. Anonymous users2024-01-29

    It's not that it doesn't work properly, it's that your judgment is wrong. If is true if is non-zero, so you need to judge d instead, and recursively call if you enter less than 2 n-1 data, it will always be waiting for input. I've modified and added the ** for you to iterate through, if the input is exactly 2 n and the 2 n is 0, then it will be created normally.

    Hope it helps!

    #include

    using namespace std;

    typedef struct bitnode

    bitree;

    t->data=d;Create a binary tree in root order first.

    coutt->lchile=createbitree(t->lchile);Create a left subtree.

    t->rchild=createbitree(t->rchild);Create a right subtree.

    return t;}}

    void inorderView(bitree &t).

    void main()

  9. Anonymous users2024-01-28

    To enter the nodes in the sequence of tree traversals, pay special attention to the fact that each leaf node must be followed by two

  10. Anonymous users2024-01-27

    I don't think it's a problem to read it, your problem is to parse it. It seems that your data structure cannot be represented by a binary tree, because the data you provide has three child nodes. It's okay to use a tree.

    The rest is parsing, which you can parse through data structures like "stacks". I've heard that the way XML tags are parsed is done through the stack. When you encounter one" ("inbound, meet one")", you will get out of the stack.

    That's probably the way it looks.

  11. Anonymous users2024-01-26

    It's okay to use a tree. The rest is parsing, which you can parse through data structures like "stacks". I've heard about xml tags.

Related questions
18 answers2024-02-08

Is your "2012-07-23" a field? If you can directly use the substitution function to replace the year, month and day with "-", it will save trouble.

9 answers2024-02-08

Agree with this. 1. Use removable disks such as USB flash drives. >>>More

8 answers2024-02-08

If it's a hard disk version of ghost, just restore it directly. >>>More

29 answers2024-02-08

Of course not, you can keep pressing the delete or del key after booting, the motherboard is different, the keys are not the same, when entering the BIOS, use the cursor key of the keyboard to select the BOOT or Advanced BIOS Features option, enter the advanced BIOS settings, select the first boot device option through the up and down cursor keys on the keyboard, after pressing the enter key to enter, after selecting the CD-ROM, In this way, the optical drive is set to the first start, and after the setting is completed, press the F10 key to save the disk and exit. This will allow you to install the Windows XP or Windows 2000 installation disk on the CD-ROM drive, and the system will automatically boot the installer from the CD-ROM drive.