//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)