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

正文內(nèi)容

樹和二叉樹實(shí)驗(yàn)報(bào)告-資料下載頁(yè)

2025-07-23 06:42本頁(yè)面
  

【正文】 ndNode(T,e)。 h=BitTreeDepth(root)。 printf(\n以%c結(jié)點(diǎn)為根的子樹深度為%d: ,e,h)。 printf(\n)。}:(六)實(shí)驗(yàn)題目6:編寫遞歸算法,求二叉樹中以元素值為x的結(jié)點(diǎn)為根的子樹的深度。:遞歸過程一般通過函數(shù)或子過程來實(shí)現(xiàn)。遞歸方法:在函數(shù)或子過程的內(nèi)部,直接或者間接地調(diào)用自己的算法。遞歸算法所體現(xiàn)的“重復(fù)”一般有三個(gè)要求:一是每次調(diào)用在規(guī)模上都有所縮小(通常是減半);二是相鄰兩次重復(fù)之間有緊密的聯(lián)系,前一次要為后一次做準(zhǔn)備(通常前一次的輸出就作為后一次的輸入);三是在問題的規(guī)模極小時(shí)必須用直接給出解答而不再進(jìn)行遞歸調(diào)用,因而每次遞歸調(diào)用都是有條件的(以規(guī)模未達(dá)到直接解答的大小為條件),無條件遞歸調(diào)用將會(huì)成為死循環(huán)而不能正常結(jié)束。:include include include define null 0 struct node { char data。 struct node *lchild。 struct node *rchild。 }。 //先序,中序 建樹 struct node *create(char *pre,char *ord,int n) { struct node * head。 int ordsit。 head=null。 if(n=0) { return null。 } else { head=(struct node *)malloc(sizeof(struct node))。 headdata=*pre。 headlchild=headrchild=null。 ordsit=0。 while(ord[ordsit]!=*pre) { ordsit++。 } headlchild=create(pre+1,ord,ordsit)。 headrchild=create (pre+ordsit+1,ord+ordsit+1,nordsit1)。 return head。 } } //中序遞歸遍歷 void inorder(struct node *head) { if(!head) return。 else { inorder(headlchild )。 printf(%c,headdata )。 inorder(headrchild )。 } } //中序非遞歸遍歷 void inorder1(struct node *head) { struct node *p。 struct node *stack[20]。 int top=0。 p=head。 while(p||top!=0) { while (p) { stack[top++]=p。 p=plchild 。 } p=stack[top]。 printf(%c ,pdata )。 p=prchild 。 } } //主函數(shù) int main() { struct node * head。 char pre[30],ord[30]。 int n。 gets(pre)。 gets(ord)。 n=strlen(pre)。 head=create(pre,ord,n)。 inorder(head)。 printf(\n)。 inorder1(head)。 printf(\n)。 }:三、總結(jié)在利用程序設(shè)計(jì)求解問題實(shí)現(xiàn)功能時(shí),我們首先要對(duì)問題進(jìn)行分析,將所要實(shí)現(xiàn)的功能分解成若干子功能來實(shí)現(xiàn),這就需要對(duì)設(shè)計(jì)方法不斷優(yōu)化。隊(duì)以同一問題,解決的方法很多,但尋求一個(gè)簡(jiǎn)單的方法,一個(gè)能夠用簡(jiǎn)單的計(jì)算機(jī)語(yǔ)言語(yǔ)句實(shí)驗(yàn)的方法,才是問題額求解方法設(shè)計(jì)的關(guān)鍵。就像本次課程設(shè)計(jì)中實(shí)現(xiàn)二叉樹樹樁輸出時(shí),有很多方法來確定二叉樹結(jié)點(diǎn)和數(shù)組的對(duì)應(yīng)關(guān)系,但適合計(jì)算機(jī)的簡(jiǎn)單方法才是最好最重要的。
點(diǎn)擊復(fù)制文檔內(nèi)容
物理相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1