freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)結(jié)構(gòu)課后習(xí)題解答第六章樹和二叉樹-文庫吧資料

2025-03-31 03:02本頁面
  

【正文】 數(shù)目{printf((%c,%c),Tdata,childdata)。{child=childnextsib)for(child=Tfirstchild。}//Insert_BiThrTree void Print_CSTree(CSTree T)//輸出孩子兄弟鏈表表示的樹T的各邊{qlchild=p。q=x。 //找到子樹中的最右結(jié)點(diǎn),并修改其前驅(qū)指向swhile(qrchild) q=qrchild。prchild=x。s=prchild。{else //x作為p的右子樹} //找到子樹中的最右結(jié)點(diǎn),并修改其前驅(qū)指向pwhile(qrchild) q=qrchild。qlchild=s。q=x。pltag=Link。 //s為p的前驅(qū)!prtag) return INFEASIBLE。if(!pltagamp。x)//在中序線索二叉樹T的結(jié)點(diǎn)p下插入子樹x{T,BiThrTree amp。return q。} //從p的雙親的右孩子向下走到底if(!qltag) q=qlchild。{while(!qltag||!qrtag)return pparent。pparenttag)else if(p==pparentlchildamp。 //p是右孩子else if(!pparent) return NULL。 //p有后繼線索else return prchild。return d。else d=(DescNum(Tlchild)+DescNum(Trchild)+2)。return OK。} //i是j的左孩子if(ij*2) ptr[j]rchild=ptr[i]。 //找到結(jié)點(diǎn)i的雙親jptr[i]data=[i]。if(![i]) return ERROR。{i++)for(i=2。ptr[1]data=[1]。return。 //空樹Bitree ptr[+1]。T,SqList sa)//根據(jù)順序存儲(chǔ)結(jié)構(gòu)建立二叉鏈表{path[h]=NULL。}if(Tlchild) Find_h(Tlchild,h+1)。{else} //打印輸出路徑i++) printf(%c,path[i]data)。for(i=1。{if(h==maxh1)return OK。if(maxh2) return ERROR。 //Bitree pathd。 Status Printpath_MaxdepthS1(Bitree T)//求深度等于樹高度減一的最靠左的結(jié)點(diǎn){return h*maxn。 //求層最大結(jié)點(diǎn)數(shù)count[i]。h=。} //利用層序遍歷來統(tǒng)計(jì)各層的結(jié)點(diǎn)數(shù)if(lchild) EnQueue(Q,{lchild,+1})。DeQueue(Q,r)。{while(!QueueEmpty(Q))InitQueue(Q)。 //count數(shù)組存放每一層的結(jié)點(diǎn)數(shù)} BTNRecord。int layer。BTNode node。 return OK。 //非法字符else if(!Print_Expression(Trchild)) return ERROR。}if(!Print_Expression(Trchild)) return ERROR。amp。else if(!Print_Expression(Tlchild)) return ERROR。} //注意在什么情況下要加括號(hào)if(!Print_Expression(Tlchild)) return ERROR。amp。if(!Tlchild||!Trchild) return ERROR。{else if(Tdata是操作符)return OK。}qdata=child。 //格式不正確) prchild=q。else if(side==39。L39。q=(BTNode*)malloc(sizeof(BTNode))。if(QueueEmpty(Q)) return ERROR。amp。amp。amp。^39。EnQueue(Q,T)。getchar()。p=T。) return ERROR。if(getchar()!=39。T)//輸入三元組建立二叉樹{return 1。}//while} //不管孩子是否為空,都入隊(duì)列EnQueue(Q,plchild)。{elseif(!p) flag=1。EnQueue(Q,T)。InitQueue(Q)。 //回溯}//Findpath int IsFull_Bitree(Bitree T)//判斷二叉樹是否完全二叉樹,是則返回1,否則返回0{!found) Findpath(Trchild,p,path,i+1)。if(Trchildamp。 //在左子樹中繼續(xù)尋找path[i]=T。} //找到found=TRUE。{if(T==p)}//Find_Near_Ancient void Findpath(Bitree T,Bitree p,Bitree path[ ],int i)//求從T到p路徑的遞歸算法{i++)。amp。for(i=0。 //求從根到p,q的路徑放在pathp和pathq中found=FALSE。}}//LayerOrder int found=FALSE。if(plchild) EnQueue(Q,plchild)。DeQueue(Q,p)。{while(!QueueEmpty(Q))InitQueue(Q)。}//while}//BiTree_Copy_Nonrecursive分析:. void LayerOrder(Bitree T)//層序遍歷二叉樹{} push(S1,prchild)。 q=qrchild。pop(S2,q)。pop(S2,q)。push(S2,q)。qdata=pdata。qlchild=(BTNode*)malloc(sizeof(BTNode))。{p)while(Gettop(S1,p)amp。{while(!StackEmpty(S))q=U。U=(BTNode*)malloc(sizeof(BTNode))。 //根指針進(jìn)棧InitStack(S2)。}//Del_Sub void Bitree_Copy_Nonrecursive(Bitree T,Bitree amp。if(Trchild) Del_Sub(Trchild)。if(Trchild) Del_Sub_x(Trchild,x)。if(Tdata==x) Del_Sub(T)。}}//Get_Depth void Del_Sub_x(Bitree T,int x)//刪除所有以元素x為根的子樹{n=Get_Depth(Trchild)。if(!T) return 0。}}//Get_Sub_Depth int Get_Depth(Bitree T)//求子樹深度的遞歸算法{ //在左右子樹中繼續(xù)尋找if(Tlchild) Get_Sub_Depth(Tlchild,x)。{else}printf(%d\n,Get_Depth(T))。{if(Tdata==x) //左右子樹再分別交換各自的左右子樹}//Bitree_Revolute int Get_Sub_Depth(Bitree T,int x)//求二叉樹中以值為x的結(jié)點(diǎn)為根的子樹深度{if(Tlchi
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1