- 33
- 0
- 约1.77万字
- 约 30页
- 2020-12-31 发布于天津
- 举报
一、 实验目的:
学会实现二叉树结点结构和对二叉树的基本操作。
掌握对二叉树每种操作的具体实现,学会利用递归方法编写对二叉树 这种递归数据结构进行处理的算法。
掌握树的创建即对它的遍历,输出树,以及叶子结点,根结点。
哈夫曼树的建立与编码的输出。
二、 实验环境:
装有Visual C++6.0的win do ns.7系统的计算机一台
三、实验内容与步骤:
.二叉树的创建及输出。
m. h文件:
D File Edit \1ew frisert Project fuild ~ools Wndoiv Hje p
用日鲁s尙鸟|a■亡J丽官甬 31*
nude 二(All chs membera] t||[Nq mcnibcrE - Creole C/Ctt- Memb^J
^include siuiu_li
flinclude nalloc.Hftdpfine 1BR
甸 Workspace xxt1: 1 pro
-?xxt files
-Source Files曹 ir.cpp固 StdAkpCpp5 xxt卬卩日 臼 Header Files
? Hl m.h^
-0 SidAfx.h
□ Resflirce Files [j| ReadMe txt
typed?F char El?mli/pe; typedeF struct node
Ele^Typt data; struct node xLchild; struct node *rchild; } BTNode;
BTNode *CreateDT1(char *pre,ct*ar fin 3nt n); BTbtode *Cre^teBT2(char ^)ostfchar ?ln9lnt n); uuld CrealtEJNuiJetBTNudfe! ? 副?咔册 *sLr); uoid PispB1Node(BTHade *b);
DTNnd^ *FinlHodp(STHndE 4bTEl?nTppc 黒〉; BTttode *LchildHode(BTHode p);
BTNode *RchdldNode(BTNode *p); int BIHod?hEight(BTHode *b);
pBTNad?(BTHode *b);
#i ncludestdafx.h
#i nclude stdio.h
#i nclude malloc.h
#defi ne MaxSize 100 typedef char ElemType; typedef struct node
{
ElemType data; struct node *lchild; /*
/*数据元素*/
指向左孩子结点*/
struct node *rchild; /*
指向右孩子结点*/
} BTNode;
BTNode 1
1 CJnsaV... 1 ^111-ileView
BTNode *CreateBT2(char *post,char *in ,i nt n); void CreateBTNode(BTNode * b,char *str); void DispBTNode(BTNode *b);
BTNode *Fi ndNode(BTNode *b,ElemType x);
BTNode *LchildNode(BTNode *p);
BTNode *RchildNode(BTNode *p);
int BTNodeHeight(BTNode *b); pBTNode(BTNode *b);
m.cpp
S jest = Microsoft Visual - (m cppll
Pl E宙 Edit iSw Irwrt Projwt Kuild Took ndcw ttelp
占H IH佯电睚0 - - 口匯時彌[
FllAII cUgg EEtnbEwjll削o mofbers ime C/C*+ Hwnb ▼ 审幽
刘 Wurkhpacr ajodl;
刘 Wurkhpacr ajodl; 1 |ro ■ ? yoCt files
d SouirM Files
ili.uLsu
1] StdAtx.cpp ^xxl.qjp
7 HRAflnr Hlcsi
S] nx h
£) StrlAftcJb _J Arcourc€ Files 三| FlRadk4c.txt
tincludfl itd^Fx.h1
tin clud s■tdlu-h
■iDC 1uds m.h
111 Hod? *CrB^tptll 1(char npre ,chjr ^in ,±nit n)
本导圭后返[3崗道曲—畏畅曲琨点扌涌*/
filNnrlp *5;
mar *p;
int k;
if (
您可能关注的文档
最近下载
- 小学2026年学雷锋主题班会教学设计(5篇).docx VIP
- 特警理论考试题库及答案.doc VIP
- 新解读《GB_T 35644 - 2017地下管线数据获取规程》最新解读.docx VIP
- (PPT,3版)跨国公司经营与管理第一章 跨国公司总论.pptx VIP
- 学雷锋纪念日主题班会.pptx VIP
- 中心组“树立和践行正确政绩观”专题研讨发言提纲.docx VIP
- 沪科黔科版综合实践活动二下 天气预报 活动一《有用的天气预报》课件.ppt VIP
- 档案鉴定销毁审批表.docx VIP
- 电子烟危害教育主题班会.pptx VIP
- 2025年初级压缩机操作工(五级)技能认定理论考试题库资料(含答案).pdf
原创力文档

文档评论(0)