Chained storage of data structure tree (tri-fork notation)

Source: Internet
Author: User

//chained storage of trees--three-prong notation#include <stdio.h>#include<stdlib.h>#include<string.h>typedefstruct_treenode{//data fields    intdata; //pointer Field    struct_treenode * LEFTCHILD;//left child pointer    struct_treenode * RIGHTCHILD;//Right Child pointer    struct_treenode * parent;//Parent pointer---- more than a binary representation of a parent pointer }treenode, *Treenodepointer;voidTest1 () {//defining the structure body objectTreeNode T1, t2, T3, T4, T5; //Populating data fieldsT1.data =1; T2.data=2; T3.data=3; T4.data=4; T5.data=5; //establish a relationship between trees//T1 is the root node T2 is T1 's left childT1.leftchild = &T2; T1.rightchild=NULL; t1.parent = NULL; //T3 is T2 's left child.T2.leftchild = &T3; T2.rightchild=NULL; t2.parent = &t1; //T4 is T2 's left child.T3.leftchild = &T4; T3.rightchild=NULL; T3.parent= &T2; //T5 is T4 's left child.T4.leftchild = &T5; T4.rightchild=NULL; T4.parent= &T2; //T5 No child nodesT5.leftchild =NULL; T5.rightchild=NULL; T5.parent= &T4;}voidMain () {System ("Pause");}

Chained storage of data structure tree (tri-fork notation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.