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

正文內(nèi)容

數(shù)據(jù)結(jié)構(gòu)線性表的基本操作-文庫吧

2025-06-15 20:54 本頁面


【正文】 tatype ptr。 tagtype tag。}stacknode。 typedef struct { stacknode a[m]。 int top。}sqstack2。Status CreateBiTree(BiTree *T){ char ch。ch=getchar()。 if(ch==39。39。) (*T)=null。 else { (*T)=(BiTree)malloc(sizeof(BiTNode))。 (*T)data=ch。 CreateBiTree(amp。(*T)lchild)。 CreateBiTree(amp。(*T)rchild)。 } return 1。}void StackInit1(sqstack *stack){ int i。 for(i=1。im。i++) (*stack).s[m]=null。 (*stack).top=0。}Status StackEmpty(sqstack stack){ if(==0) return 1。 else return 0。}void Visit(TElemType e){printf(%c,e)。}void Push1(sqstack *stack,datatype x){ if((*stack).top==m1) printf(The Stack is overflow!)。 else { (*stack).top=(*stack).top+1。 (*stack).s[(*stack).top]=x。 }}datatype Pop1(sqstack *stack){ datatype y。 if((*stack).top==0) printf(The Stack is overflow!)。 else { y=(*stack).s[(*stack).top]。 (*stack).top=(*stack).top1。 return y。 }}void PreOrderBiTree(datatype t){ datatype p=t。 sqstack s。 StackInit1(amp。s)。 while(p!=null||!StackEmpty(s)) { while(p!=null) { Visit(pdata)。 Push1(amp。s,p)。 p=plchild。 } if(!StackEmpty(s)) { p=Pop1(amp。s)。 p=prchild。 }/*endif*/ }}void InOrderBiTree(datatype t){ datatype p=t。 sqstack s。 StackInit1(amp。s)。 while(p!=null||!StackEmpty(s)) { while(p!=null) { Push1(amp。s,p)。 p=plchild。 } if(!StackEmpty(s)) { p=Pop1(amp。s)。 Visit(pdata)。 p=prchild。 } }}void StackInit2(sqstack2 *stack){(*stack).top=0。}Status StackEmpty2(sqstack2 stack){ if(==0) return 1。 else return 0。}void Push2(sqstack2 *stack,stacknode x){ if((*stack).top==m1) printf(The Stack is overflow!)。 else { (*stack).top=(*stack).top+1。 (*stack).a[(*stack).top]=x。 }}stacknode Pop2(sqstack2 *stack){ stacknode y。 if((*stack).top==0) printf(The Stack is overflow!)。 else { y=(*stack).a[(*stack).top]。 (*stack).top=(*stack).top1。 return y。 }}void PostOrderBiTree(datatype t){ datatype p=t。 sqstack2 s。 stacknode x。 StackInit2(amp。s)。 do { while(p!=null) { =p。 =L。 Push2(amp。s,x)。 p=plchild。 } while(!StackEmpty2(s)amp。amp。[].tag==R) { x=Pop2(amp。s)。 p=。 Visit(pdata)。 } if(!StackEmpty2(s)) { [].tag=R。 p=[].ptrrchild。 } } while(!StackEmpty2(s))。}main(){ BiTree T=null。 printf(\nCreate a Binary Tree in PreOrder\n)。 CreateBiTree(amp。T)。 printf(The PreOrder of the Binary Tree is:)。 PreOrderBiTree(T)。 printf(\n)。 printf(\nThe InOrder of the Binary Tree is :)。 InOrderBiTree(T)。 printf(\n)。 printf(\nThe PostOrde of the Binary Tree is:)。 PostOrderBiTree(T)。}七、測試數(shù)據(jù)建立如右圖所示的二叉樹,以字符串的形式“根 左子樹 右子樹”先序定義一棵二叉樹。輸入數(shù)據(jù)次序?yàn)椋篈BDHECFG(號代表空格)八、測試情況輸出結(jié)果: 題目二一、問題描述對任意給定的樹(頂點(diǎn)數(shù)自定)建立它的二叉鏈表存儲結(jié)構(gòu),并利用棧的五種基本運(yùn)算(置空棧、進(jìn)棧、出棧、取棧頂元素、判??眨?shí)現(xiàn)樹的先根,后根兩種遍歷,輸出兩種遍歷的結(jié)果。二、基本要求1將給定的樹轉(zhuǎn)換成二叉樹。2對給定節(jié)點(diǎn),建立二叉鏈表存儲結(jié)構(gòu);3 利用棧的上述五種基本運(yùn)算實(shí)現(xiàn)先根、后根兩種遍歷。4 輸出兩種遍歷結(jié)果。三、算法思想以字符串的形式“根 子樹”將一棵樹創(chuàng)建為一棵二叉樹。利用棧的五種基本運(yùn)算(置空棧、進(jìn)棧、出棧、取棧頂元素、判??眨?shí)現(xiàn)樹的先根、后根兩種遍歷,輸出兩種遍歷結(jié)果(樹的先根、后根遍歷分別于
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1