【正文】
通過(guò)課程設(shè)計(jì)自己對(duì)《數(shù)據(jù)結(jié)構(gòu)》這門課程有了更深一層的了解,意識(shí)到了數(shù)據(jù)結(jié) 構(gòu)的重要性,同時(shí)也對(duì) c 語(yǔ)言的掌握更進(jìn)一步,熟悉了長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) 18 對(duì)于指針,鏈表,隊(duì)列等的操作, 對(duì)程序設(shè)計(jì)的過(guò)程也有了自己的一些理解:首先,要對(duì)到手的問(wèn)題要認(rèn)真思考,如何實(shí)現(xiàn),用何種方法實(shí)現(xiàn),力求最簡(jiǎn),在保證正確性的基礎(chǔ)上提高程序效率;其次,確定了實(shí)現(xiàn)的方法之后就要用程序語(yǔ)言將想法表示出來(lái);最后,進(jìn)行調(diào)試和排錯(cuò),一個(gè)有效的方法是在前面遇到問(wèn)題時(shí)在旁邊加上必要的注釋,進(jìn)行調(diào)試的時(shí)候可以盡快看清問(wèn)題所在。 ,例如創(chuàng)建的二叉樹是空樹還是滿二叉樹;對(duì)創(chuàng)建的二叉樹進(jìn)行查找,刪除,插入,匹配;如何解決程序順利執(zhí)行而不會(huì)陷入死循環(huán)一些問(wèn)題等等。圖中數(shù)字是各函數(shù)的編號(hào) 。 leafNum=CountLeaf(T)。//葉子數(shù)目加 1 else//不為葉子結(jié)點(diǎn) { CountLeaf(Tleft)。 TnodeValue=nodeValue。//左子樹 TNode* right。 exchange(root)。 printf(% d,btdata)。 } return t。int x。 //j 為右子樹的深度 長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) 8 J= BinTreeDepth(BinTree Trchild)。 PreOrderTraverse(T,visit)。 // 最后中序遍歷右子樹 } } 長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) 7 void PostOrderTraverse(BiTree T,void(*Visit)(int)) { // 初始條件:二叉樹 T 存在, Visit 是對(duì)結(jié)點(diǎn)操作的應(yīng)用函數(shù) // 操作結(jié)果:后序遞歸遍歷 T,對(duì)每個(gè)結(jié)點(diǎn)調(diào)用函數(shù) Visit一次且僅一次 if(T) // T 不空 {PostOrderTraverse(Tlchild,Visit)。 // 釋放根結(jié)點(diǎn) T=NULL。 Tdata=number。T) { // 算法 :按先序次序輸入二叉樹中結(jié)點(diǎn)的值 (可為字符型或整型,在主程中定義 ), // 構(gòu)造二叉鏈表表示的二叉樹 T。中序遍歷的原則:若被遍歷的二叉樹為非空,則依次執(zhí)行如下操作: 長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) 5 include // malloc()等 include // 標(biāo)準(zhǔn)輸入輸出頭文件,包 括 EOF(=^Z 或 F6), NULL 等 include // atoi(), exit() include // 數(shù)學(xué)函數(shù)頭文件,包括 floor(), ceil(), abs()等 define ClearBiTree DestroyBiTree // 清空二叉樹和銷毀二叉樹的操作一樣 typedef struct BiTNode { int data。 Tdata=ch。 LevelOrderTraverse(T):層次遍歷二叉樹,并輸出結(jié)點(diǎn)序列。 ( 4)將二叉樹中所有結(jié)點(diǎn)的左右子樹相互交換。 ,包括將所有方法歸并在一起,還要建立查看界面一邊有系統(tǒng)的視覺(jué)效果。 長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) 2 設(shè)計(jì)思想 。二叉樹是一種非線性數(shù)據(jù)結(jié)構(gòu),對(duì)它進(jìn)行操作時(shí)總需要對(duì)每個(gè)數(shù)據(jù)逐一進(jìn)行操作,這樣就存在一個(gè)操作順序問(wèn)題,由此提出了二叉樹的遍歷操作問(wèn)題,所謂遍歷二叉樹就是按某種順序訪問(wèn)二叉樹中某個(gè)結(jié)點(diǎn)一次且僅一次的過(guò)程,這里的訪問(wèn)可以是輸出 .比較 .更新 .查看 元素內(nèi)容等各種操作。 關(guān)鍵詞 :二叉樹; 左子樹; 右子樹長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì) (論文) II Abstract In many real world of plex data, such as the human society family, social anization, widespread game traffic plex thing or process and the objective world with a branch or level characteristics of the object. If the operating system file analysis, artificial intelligence and algorithm model representation and database information system the form of anization, with a linear structure to express the logic relationship among them, must depend on the number and the diagram of such nonlinear structure, so in order to simulate the objective world, solve problems as the main task of the puter field in the tree structure is an important anization form of information, the tree has a broad application. In the application of tree structure in which the two fork tree is the most monly used. Two binary tree is a kind of very important nonlinear structure, hiberarchy description of the data, where each element is only a precursor, two fork tree is the most monly used data structure, its application is very extensive, there are three kinds of two binary tree traversal, preorder traversal, in the traversal, postorder traversal, preorder traversal sequence: NLR to the root node, and then the left subtree, right subtree。 長(zhǎng)春建筑學(xué)院《數(shù)據(jù)結(jié)構(gòu)》課程設(shè)計(jì)(論文) 基于二叉樹遍歷系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn) Binary tree traversal System Design and Implementation 年 級(jí) : 學(xué) 號(hào) : 姓 名 : 專 業(yè) : 指導(dǎo)老師 : 二零一三年十二月長(zhǎng)春建筑學(xué)院《數(shù)據(jù) 結(jié)構(gòu)》課程設(shè)計(jì) (論文) I 摘 要 針對(duì)現(xiàn)實(shí)世界中許多關(guān)系復(fù)雜的數(shù)據(jù),如人類社會(huì)的家譜,各種社會(huì)組織機(jī)構(gòu) ,博弈交通等復(fù)雜事物或 過(guò)程以及客觀世界中廣泛存在的具有分支關(guān)系或?qū)哟翁匦缘膶?duì)象.如操作系統(tǒng)的文件構(gòu)成、人工智能和算法分析的模型表示