树,二叉树的创建及输出.哈夫曼编码的输出.docxVIP

  • 33
  • 0
  • 约1.77万字
  • 约 30页
  • 2020-12-31 发布于天津
  • 举报

树,二叉树的创建及输出.哈夫曼编码的输出.docx

一、 实验目的: 学会实现二叉树结点结构和对二叉树的基本操作。 掌握对二叉树每种操作的具体实现,学会利用递归方法编写对二叉树 这种递归数据结构进行处理的算法。 掌握树的创建即对它的遍历,输出树,以及叶子结点,根结点。 哈夫曼树的建立与编码的输出。 二、 实验环境: 装有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.H ftdpfine 1BR 甸 Workspace xxt1: 1 pro -?xxt files -Source Files 曹 ir.cpp 固 StdAkpCpp 5 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 (

文档评论(0)

1亿VIP精品文档

相关文档