- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
排序二叉树简易模板_by_jason(Sort two fork tree simple template _by_jason)
排序二叉树简易模板_by_jason(Sort two fork tree simple template _by_jason)
# includes stdio.h
# includes stdio.h
# includes malloc.h
# includes time.h
# define n 10
# define nodetype struct node
# define qnodetype struct qnode
# define treetype struct tree
# define queuetype struct.
# define elemtype int
# define qelemtype nodetype *
# define root mytree - root
# define mem _ tree (treetype *) malloc (sizeof (treetype))
# define mem _ node (nodetype *) malloc (sizeof (nodetype))
# define mem _ qnode (qnodetype *) malloc (sizeof (qnodetype))
# define mem _ queue (queuetype *) malloc (sizeof (queuetype))
# define randn random ()% n
# define randinit srandom (time (null))
nodetype
{/ / 二叉树节点
elemtype date;
nodetype * left;
nodetype * right;
};
qnodetype
{/ / 辅助队列节点, 用于层遍历
qelemtype date;
qnodetype * next;
};
treetype
{/ / 二叉树的根指针
nodetype * root;
};
queuetype
{/ / 队列的前后指针
qnodetype * front;
qnodetype * rear;
};
nodetype * pre; / / 定义全局变量, 用于删除操作储存父节点
qnodetype * created _ those _ node (qelemtype elem); / / 返回一个新的队列节点
queuetype * init _ queue (); / / 初始化队列
int empty _ queue (queuetype * q); / / 判断队列是否为空
void en _ queue (queuetype * q, qelemtype elem); / / 给队列插入一个节点
qelemtype de _ queue (queuetype * q); / / 删除一个队列节点
nodetype * created _ tree _ node (elemtype elem); / / 返回一个树节点
treetype * init _ tree (nodetype * rootnode); / / 初始化树
void insert _ ord (nodetype * root, elemtype elem); / / 按序插入二叉树
void in _ order (nodetype * root, treetype * mytree); / / 中序输出二叉树
void pre _ order (nodetype * root, treetype * mytree); / / 前序输出二叉树
void post _ order (nodetype * root, treetype * mytree); / / 后序输出二叉树
void level _ order (treetype * mytree); / / 层遍历并输出
int height _ tree (treetype * mytree); / / 返回二叉树的深度
void delete _ tree (nodetype * root, treetype * mytree, elemtype elem); / / 删除二叉树的一个节点
int main ()
{
int i = 0;
randinit;
nodetype * rootnode = created _ tree _ node (n / 2);
treetype * mytree = init _ tree (rootnode);
for (i = 0; i n; i + +)
insert _ ord (root, randn);
/ / pre _ ord
您可能关注的文档
- 少白头的中医调理方法(Chinese medicine conditioning method with Shao Baitou).doc
- 小学语文词语 汇编 词语种类(Primary school Chinese words assembly words and phrases).doc
- 就业问题研讨总结(Summary of research on Employment).doc
- 少先队组织教育(Young pioneers; organizational Education).doc
- 就成本谈成本(Talking about cost in terms of cost).doc
- 局域网ping不通原因及解决方法(Reason and solution of Ping obstruction in LAN).doc
- 局部最佳页面替换算法(Local optimum page replacement algorithm).doc
- 小额贷款规章(Small loan regulations).doc
- 层次论与辩证法的充实和发展(The enrichment and development of the theory of hierarchy and Dialectics).doc
- 屏闭ecshop不要的功能(Screen ECSHOP not function).doc
- 掌握这些电脑知识,你可以玩的很无耻(Master these computer knowledge, you can play very shameless).doc
- 招聘是招待,面试是恋爱(Recruitment is entertainment, interview is love).doc
- 排队机维修资料(Queuing machine maintenance data).doc
- 探索企业管理本质《一企业培训》---肉麻式 管理(To explore the essence of enterprise management training --- disgusting management).doc
- 探讨秒时代的微博营销攻略(Probe into the marketing strategy of micro-blog in seconds era).doc
- 探索管理会计成为常态工作(Exploring management accounting has become routine).doc
- 控制器说明书(Controller manual).doc
- 推动海南文化大发展大繁荣(Promote the great development and prosperity of Hainan culture).doc
- 推动企业转型 用文化企业培训改变企业(Promote enterprise transformation, culture, enterprise training, change the enterprise).doc
- 探索培养机制,倡导个性发展(Explore the training mechanism, and promote personality development).doc
文档评论(0)