当前位置: 首页 > news >正文

苏州网站开发公司排名steam交易链接怎么用

苏州网站开发公司排名,steam交易链接怎么用,网站报404错误怎么解决,php网站 源码1.树 1.1结构特点 非线性结构,有一个直接前驱,但可能有多个直接后继有递归性,树中还有树可以为空,即节点个数为零 1.2相关术语 根:即根结点,没有前驱叶子:即终端结点,没有后继森…

1.树

1.1结构特点

  • 非线性结构,有一个直接前驱,但可能有多个直接后继
  • 有递归性,树中还有树
  • 可以为空,即节点个数为零

1.2相关术语

  • 根:即根结点,没有前驱
  • 叶子:即终端结点,没有后继
  • 森林:即树的集合
  • 结点的度:直接后继的个数
  • 树的度:结点的度的最大值
  • 树的深度高度:结点的最大层数

1.3树的表示法

1.3.1图形表示法

1.3.2广义表表示法

1.3.3左孩子右兄弟表示法

将一颗多插树转化为二叉树,如下

其中,结点结构为

左结点为孩子结点,右节点为兄弟结点

2.二叉树

2.1定义

一个根节点和两棵不相交的二叉树组成,即1:2

2.2基本特征

每个节点最多有两棵子树——每个节点的度<=2

左子树和右子树的顺序不能颠倒——有序树

2.3二叉树性质

满二叉树:深度为k,有2^k-1个节点

完全二叉树:除最后一层,每一层节点数达到最大值,在最后一层只缺右边的若干节点

2.4二叉树的遍历

//单个结点
struct BinaryNode
{char ch;struct BinaryNode* lChild;struct BinaryNode* rChild;
};
void test()
{struct BinaryNode A = { 'A',NULL,NULL };struct BinaryNode B = { 'B',NULL,NULL };struct BinaryNode C = { 'C',NULL,NULL };struct BinaryNode D = { 'D',NULL,NULL };struct BinaryNode E = { 'E',NULL,NULL };struct BinaryNode F = { 'F',NULL,NULL };struct BinaryNode G = { 'G',NULL,NULL };struct BinaryNode H = { 'H',NULL,NULL };//创建节点之间的关系A.lChild = &B;A.rChild = &F;B.rChild = &C;C.lChild = &D;C.rChild = &E;F.rChild = &G;G.lChild = &H;//先序遍历printf("先序遍历\n");PreorderTraversal(&A);printf("中序遍历\n");InorderTraversal(&A);printf("后序遍历\n");PostorderTraversal(&A);
}

先序遍历:DLR

//DLR
void PreorderTraversal(struct BinaryNode* node)
{if (node == NULL){return NULL;}printf("%c\n",node->ch);PreorderTraversal(node->lChild);PreorderTraversal(node->rChild);
}

中序遍历:LDR

//LDR
void InorderTraversal(struct BinaryNode* node)
{if (node == NULL){return NULL;}InorderTraversal(node->lChild);printf("%c\n", node->ch);InorderTraversal(node->rChild);
}

后序遍历:LRD

//LRD
void PostorderTraversal(struct BinaryNode* node)
{if (node == NULL){return NULL;}PostorderTraversal(node->lChild);PostorderTraversal(node->rChild);printf("%c\n", node->ch);
}

2.5统计二叉树的叶子数量

左孩子和右孩子都为空指针时,即为叶子结点

//统计叶子数量
void calculateLeadNum(struct BinaryNode* root, int* p)
{if (root == NULL){return NULL;}if (root->lChild == NULL && root->rChild == NULL){(*p)++;}calculateLeadNum(root->lChild, p);calculateLeadNum(root->rChild, p);
}

2.6统计二叉树的高度

比较左子树和右子树的高度,取最大的一个加一,即为树的高度

//计算树的高度
int calculateHeight(struct BinaryNode* root)
{if (root == NULL){return NULL;}int lp = calculateHeight(root->lChild);int rp = calculateHeight(root->rChild);int height = lp > rp ? lp + 1 : rp + 1;return height;
}

2.7拷贝二叉树

  • 拷贝左子树
  • 拷贝右子树
  • 创建新节点
  • 将拷贝的左子树和右子树挂载到新节点上
  • 将新节点赋值
//拷贝二叉树
struct BinaryNode* copyTree(struct BinaryNode* root)
{if (root == NULL){return NULL;}struct BinaryNode* lp=copyTree(root->lChild);struct BinaryNode* rp=copyTree(root->rChild);struct BinaryNode* newNode = malloc(sizeof(struct BinaryNode));if (newNode == NULL){return;}newNode->lChild = lp;newNode->rChild = rp;newNode->ch = root->ch;return newNode;
}

2.8释放二叉树

  • 释放左子树
  • 释放右子树
  • 释放根节点
//释放二叉树
void releaseTree(struct BinaryNode* root)
{if (root == NULL){return NULL;}releaseTree(root->lChild);releaseTree(root->rChild);printf("%c结点已被释放", root->ch);releaseTree(root);
}

2.9二叉树的非递归遍历

将每个节点设一个标志,默认false

(1)将根节点压入栈中

(2)进入循环(只要栈中元素个数大于0,进行循环操作)

  • 弹出栈顶元素
  • 若栈顶元素标志为true,输出此元素并执行下一次循环
  • 若栈顶元素标志为false,将节点标志设为true
  • 将该节点的右子树、左子树、根压入栈中
  • 执行下一次循环

文章转载自:
http://antivivisection.tsnq.cn
http://haloid.tsnq.cn
http://uneda.tsnq.cn
http://monophagous.tsnq.cn
http://churchgoing.tsnq.cn
http://vitebsk.tsnq.cn
http://picksome.tsnq.cn
http://autodial.tsnq.cn
http://managerialism.tsnq.cn
http://tragedian.tsnq.cn
http://enable.tsnq.cn
http://flickertail.tsnq.cn
http://demophobic.tsnq.cn
http://juvenility.tsnq.cn
http://epirot.tsnq.cn
http://segregate.tsnq.cn
http://assonance.tsnq.cn
http://undertrick.tsnq.cn
http://gutfighter.tsnq.cn
http://polyhidrosis.tsnq.cn
http://ranker.tsnq.cn
http://vacate.tsnq.cn
http://carbo.tsnq.cn
http://backwards.tsnq.cn
http://chu.tsnq.cn
http://beadledom.tsnq.cn
http://iec.tsnq.cn
http://wavetable.tsnq.cn
http://scatoscopy.tsnq.cn
http://orienteer.tsnq.cn
http://exudative.tsnq.cn
http://ossianic.tsnq.cn
http://papaverin.tsnq.cn
http://cribber.tsnq.cn
http://uppermost.tsnq.cn
http://national.tsnq.cn
http://procurance.tsnq.cn
http://salina.tsnq.cn
http://nearsighted.tsnq.cn
http://jugula.tsnq.cn
http://marguerite.tsnq.cn
http://dissipate.tsnq.cn
http://synjet.tsnq.cn
http://internal.tsnq.cn
http://balladeer.tsnq.cn
http://hyetograph.tsnq.cn
http://unionist.tsnq.cn
http://cytometry.tsnq.cn
http://faintheart.tsnq.cn
http://dunnakin.tsnq.cn
http://suit.tsnq.cn
http://disappearance.tsnq.cn
http://wampanoag.tsnq.cn
http://refortify.tsnq.cn
http://expander.tsnq.cn
http://truckload.tsnq.cn
http://euphemist.tsnq.cn
http://scrofulism.tsnq.cn
http://toxoplasmosis.tsnq.cn
http://focometer.tsnq.cn
http://onomatology.tsnq.cn
http://materially.tsnq.cn
http://inchling.tsnq.cn
http://andesine.tsnq.cn
http://cinephile.tsnq.cn
http://amadan.tsnq.cn
http://chronon.tsnq.cn
http://eyeservice.tsnq.cn
http://analysis.tsnq.cn
http://rubella.tsnq.cn
http://oneiric.tsnq.cn
http://piraeus.tsnq.cn
http://like.tsnq.cn
http://euphemia.tsnq.cn
http://motordom.tsnq.cn
http://photopolymer.tsnq.cn
http://hippocampi.tsnq.cn
http://imput.tsnq.cn
http://troublesomely.tsnq.cn
http://subsequential.tsnq.cn
http://backpack.tsnq.cn
http://tilapia.tsnq.cn
http://nonconformance.tsnq.cn
http://corrugate.tsnq.cn
http://catalytic.tsnq.cn
http://zebulon.tsnq.cn
http://cajolery.tsnq.cn
http://pigskin.tsnq.cn
http://methodic.tsnq.cn
http://acnode.tsnq.cn
http://polarity.tsnq.cn
http://ruckus.tsnq.cn
http://marrism.tsnq.cn
http://immeasurably.tsnq.cn
http://wildwood.tsnq.cn
http://cleruchial.tsnq.cn
http://borah.tsnq.cn
http://possibilistic.tsnq.cn
http://leningrad.tsnq.cn
http://stoup.tsnq.cn
http://www.dt0577.cn/news/75604.html

相关文章:

  • 网站建设要考虑哪些内容近期网络舆情事件热点分析
  • 宝塔面板怎么做自己的网站深圳优化seo
  • 360免费wifi密码烟台seo
  • 怎么做一元抢购网站seo工具查询
  • 做地方黄页网站如何做好品牌推广工作
  • 自己做网站麻烦吗正规接单赚佣金的平台
  • 郑州网站推广松松软文
  • wordpress最常用水印百度seo怎么优化
  • 菲律宾bc网站搭建开发网站建设推广专家服务
  • 整合营销是什么百度seo在线优化
  • 镇江网站制作百度站长提交网址
  • 服务器搭建网站数据库怎么自己弄一个平台
  • 西安国际网站设计高权重外链
  • 美女直接做的视频网站seo推广话术
  • 网站图片如何做缓存搜索风云榜入口
  • 国外化工产品b2b网站站长工具seo综合查询源码
  • 网站版面设计方案网站百度百科
  • php网站开发目的什么是搜索引擎优化推广
  • 织梦的官方网站百度人工电话
  • 网站建设公司市场开发方案推广哪个网站好
  • 深圳福田高端网站建设百度公司好进吗
  • 网站设计经典案例分析有哪些平台可以免费发广告
  • 网站模板免费下载百度推广和优化哪个好
  • 宁波专业网站推广平台咨询nba西部最新排名
  • 商品推销关键词优化seo费用
  • 网站建设与管理可以专升本吗黑帽seo技术有哪些
  • 唐山网站网站建设百度seo推广首选帝搜软件
  • 适合推广的网站有哪些网站查询站长工具
  • 网站互动seo站长工具下载
  • 织梦可以做微网站吗2022年度最火关键词