usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Collections.Generic;namespaceConsoleApplication4{classProgram{staticvoidMain(string[]args){personalInfop1=newpersonalInfo("1","1");personalInfop2=newpersonalInfo("2","2");personalInfop3=newpersonalInfo("3","3");personalInfop4=newpersonalInfo("","");personalInfop31=newpersonalInfo("31","31");personalInfop32=newpersonalInfo("32","32");personalInfop33=newpersonalInfo("","");personalInfop321=newpersonalInfo("","");personalInfop311=newpersonalInfo("","");personalInfop21=newpersonalInfo("","");personalInfop11=newpersonalInfo("11","11");personalInfop12=newpersonalInfo("","");personalInfop111=newpersonalInfo("","");List<personalInfo>list=newSystem.Collections.Generic.List<personalInfo>();list.AddRange(newpersonalInfo[]{p1,p2,p3,p4,p31,p32,p33,p321,p311,p21,p11,p12,p111});JiaPuj=newJiaPu(list);notephead=null;intindex=j.CreateTree(refphead,0,13);}publicstructpersonalInfo{publicpersonalInfo(stringname,stringId){this.name=name;this.Id=Id;}publicstringname;publicstringId;//Idisemptyornull,thatmeans,notheperson.}publicclassnote{publicpersonalInfodata;publicnotelChild,rChild;}publicclassJiaPu{List<personalInfo>persons;//intindex=0;publicJiaPu(List<personalInfo>persons){this.persons=persons;}publicintCreateTree(refnotenNode,intindex,intlength){if(index>=length){nNode=null;returnindex;}if(string.IsNullOrEmpty(persons[index].Id)){nNode=null;returnindex;}nNode=newnote();nNode.data=persons[index];index=CreateTree(refnNode.lChild,++index,length);index=CreateTree(refnNode.rChild,++index,length);returnindex;}}}}