Data Structure 之 二叉树
(2)只有一个根结点的二叉树
个结点(h>=1),最少有h个结点;
typenode=record
data:datatype
l,r:integer;
end;
vartr:array[..n]ofnode;
typebtree=^node;
node=record
data:datatye;
lchild,rchild:btree;
end;
7、辨析
void XXBL(tree*root){
//DoSomethingwithroot
if(root->lchild!=NULL)
XXBL(root->lchild);
if(root->rchild!=NULL)
XXBL(root->rchild);
}
[2]中序遍历:首先中序遍历左(右)子树,再访问根,最后中序遍历右(左)子树,C语言代码如下
void ZXBL(tree*root)
{
if(root->lchild!=NULL)
ZXBL(root->lchild);//DoSomethingwithroot
if(root->rchild!=NULL)
ZXBL(root->rchild);
}
[3]后序遍历:首先后序遍历左(右)子树,再后序遍历右(左)子树,最后访问根,C语言代码如下
void HXBL(tree*root){
if(root->lchild!=NULL)
HXBL(root->lchild);
if(root->rchild!=NULL)
HXBL(root->rchild);//DoSomethingwithroot
}
[4]层次遍历
[5]线索二叉树
Data Structure 之 二叉树的更多相关文章
- CDOJ 483 Data Structure Problem DFS
Data Structure Problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/proble ...
- 【LeetCode】211. Add and Search Word - Data structure design 添加与搜索单词 - 数据结构设计
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:Leetcode, 力扣,211,搜索单词,前缀树,字典树 ...
- [LeetCode] All O`one Data Structure 全O(1)的数据结构
Implement a data structure supporting the following operations: Inc(Key) - Inserts a new key with va ...
- [LeetCode] Add and Search Word - Data structure design 添加和查找单词-数据结构设计
Design a data structure that supports the following two operations: void addWord(word) bool search(w ...
- [LeetCode] Two Sum III - Data structure design 两数之和之三 - 数据结构设计
Design and implement a TwoSum class. It should support the following operations:add and find. add - ...
- Finger Trees: A Simple General-purpose Data Structure
http://staff.city.ac.uk/~ross/papers/FingerTree.html Summary We present 2-3 finger trees, a function ...
- Mesh Data Structure in OpenCascade
Mesh Data Structure in OpenCascade eryar@163.com 摘要Abstract:本文对网格数据结构作简要介绍,并结合使用OpenCascade中的数据结构,将网 ...
- ✡ leetcode 170. Two Sum III - Data structure design 设计two sum模式 --------- java
Design and implement a TwoSum class. It should support the following operations: add and find. add - ...
- leetcode Add and Search Word - Data structure design
我要在这里装个逼啦 class WordDictionary(object): def __init__(self): """ initialize your data ...
随机推荐
- 使用Java程序调用MatLab
Java代码实现的计算难免会显得不够高效.而利用MATLAB写好相应的计算函数,然后打包成jar包供Java调用,在某些情况下会更加方便.或者有些时候会涉及到使用Java调用MatLab展现一些二维三 ...
- 关于在 mac上配置pytesseract的相关问题
因为踩了两个小时坑 特别是在配置依赖tesseract-ORC识别库时候的问题 特别麻烦 一定要用brewhome 一定要用brewhome 一定要用brewhome 重要的事情说三遍. 刚开始我在网 ...
- 帮你选处理器:CPU T9500-p9500-T9400-T9300-p8700对比分析!
许多人对处理器是P和T开头含混不清,不甚了解,也怪英特尔的处理器型号实在是太过复杂.这需要具体型号来看的.让我们先来看看英特尔的官方解释吧 T: Mobile Highly Performance-- ...
- HTML5-企业宣传6款免费源码
本文主要分享了6个很不错的HTML5宣传模板源码,这些生动具体的介绍了各个公司的产品及公司各类应用,有汽车.旅游.公司,房产等Query特效,大家一起来欣赏吧. 一.九秒教育企业海报(移动端)这次要分 ...
- CCPC总结
[印象·南阳] 10月15日出发,威海—烟台—郑州—南阳,一路上欢声笑语,从谁是卧底到各类纸牌游戏,也是欢乐.在从郑州到南阳的车上,对面的好像是河南当地的学长,感叹道工作不易的样子,说还是学生时代最为 ...
- jquery easyui datagraid 对象显示的方法与datagraid、分页、复选框多选的数据显示
========================jsp==============================<table id="dg" fit="true& ...
- Gulp 学习总结
Gulp 自动化工具开发非常方便,便于上手,值得使用. 一.Gulp安装 gulp是基于NodeJS运行的,所以需要想安装NodeJS. http://nodejs.org/download/ 安装 ...
- 开发中,如何配合后端,保存你的静态html页
添加备注2015.4.8 最终决定采用相对路径方法, /img/img.jpg这种“绝对”路径写法必须在网站环境中才能识别,不利于静态页面的查看,故不予采用! 所以采用img/img.jpg或../i ...
- The Aggregate Magic Algorithms
http://aggregate.org/MAGIC/ The Aggregate Magic Algorithms There are lots of people and places that ...
- php safe mode bypass all <转>
PHP safe mode bypass from 4.x to 5.x all. Functions: * mb_send_mail* curl_init* imap_open* mail* ion ...