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

奥巴马在竞选中使用了那些网络营销方式搜索关键词排名优化技术

奥巴马在竞选中使用了那些网络营销方式,搜索关键词排名优化技术,如何把网站扒下来,新手可以做网站营运吗目录 一.前言 二.模拟实现链式结构的二叉树 2.1二叉树的底层结构 2.2通过前序遍历的数组"ABD##E#H##CF##G##"构建二叉树 2.3二叉树的销毁 2.4二叉树查找值为x的节点 2.5二叉树节点个数 2.6二叉树叶子节点个数 2.7二叉树第k层节点个数 三.二叉树的遍历 3.1…

目录

一.前言

二.模拟实现链式结构的二叉树

2.1二叉树的底层结构

2.2通过前序遍历的数组"ABD##E#H##CF##G##"构建二叉树

2.3二叉树的销毁

2.4二叉树查找值为x的节点

2.5二叉树节点个数

2.6二叉树叶子节点个数

2.7二叉树第k层节点个数

三.二叉树的遍历

3.1前序遍历

3.2中序遍历

3.3后序遍历

3.4层序遍历


一.前言

详解—数据结构《树和二叉树》-CSDN博客

上一节课我们详解了树和二叉树,这一篇博客我来带领大家来模拟实现二叉树

二.模拟实现链式结构的二叉树

2.1二叉树的底层结构

首先,有一个数据域

然后有俩个二叉树指针,分别指向他们的左孩子和右孩子

typedef char BTDataType;
typedef struct BinaryTreeNode
{BTDataType data;struct BinaryTreeNode* left;struct BinaryTreeNode* right;
}BTNode;

2.2通过前序遍历的数组"ABD##E#H##CF##G##"构建二叉树

1、按照前序遍历(先走根,再走左子树,再走右子树)的方法,我们首先了解大概思路

2、数组里面的#就相当于为空,所以,我们先判断if 我们的数组为#,就返回空

3、然后我们创建一个节点,如果开辟失败,返回空,我们进行判断

4、然后放入数据,

5、再然后递归开始走左子树,右子树

BTNode* BinaryTreeCreate(BTDataType* a, int n, int * pi)
{if ('#' == a[*pi]){++(*pi);return NULL;}BTNode * root = (BTNode *)malloc (sizeof(BTNode));if (root == NULL){perror("malloc");return;}root->data = a[(*pi)++];root->left = BinaryTreeCreate(a, n, pi);root->right = BinaryTreeCreate(a, n, pi);return root;
}

2.3二叉树的销毁

销毁一颗二叉树

1.首先判断如果是空树,直接返回

2.利用递归从最左边的树开始进行一个节点一个节点的删除

void BinaryTreeDestory(BTNode** root)
{if (*root == NULL)return;BinaryTreeDestory((*root)->left);BinaryTreeDestory((*root)->right);free(*root);*root = NULL;
}

2.4二叉树查找值为x的节点

二叉树的查找在这里我用的前序遍历递归

1.先确定递归的退出条件,root等于空就返回

2.然后进行前序遍历

3.判断一下当前节点是不是x

4.在开始走左子树

5.开始走右子树

BTNode* BinaryTreeFind(BTNode* root, BTDataType x)
{BTNode* node;if (root == NULL)return NULL ;//一开始就是 xif (root->data == x){return root;}//前序遍历寻找xnode = BinaryTreeFind(root->left, x);if (node)return node;node =BinaryTreeFind(root->right, x);if (node)return node;//遍历完找不到返回空return NULL;
}

2.5二叉树节点个数

二叉树的节点个数就是二叉树,左子树加上右子树加上根

这里我用的也是递归的方法,同学们可以看一下

int BinaryTreeSize(BTNode* root)
{return root == NULL ? 0 : BinaryTreeLeafSize(root->left) + BinaryTreeLeafSize(root->right) + 1; 
}

2.6二叉树叶子节点个数

叶节点或终端节点:度为0的节点称为叶节点;

可以观看上一篇文章取了解叶子节点

详解—数据结构《树和二叉树》-CSDN博客

查找叶子节点,也是用的递归方法,

首先,增加递归退出条件root==0

然后,如果所在的节点他的左右子树都为空,那么他就是叶子节点,返回1

最后递归遍历所有的叶子节点进行相加

int BinaryTreeLeafSize(BTNode* root)
{if (root == NULL){return 0;}if (root->left == NULL && root->right == NULL){return 1;}return BinaryTreeLeafSize(root->left) + BinaryTreeLeafSize(root->right);
}

2.7二叉树第k层节点个数

在二叉树中我们想知道,每一层有多少个节点

1.确定递归退出条件

2.如果k=1,返回1,代表找到了这一层的一个节点

3.进行递归,每一层k-1,当k=1是找到所在k层,返回一,进行相加查找当前层数据

int BinaryTreeLevelKSize(BTNode* root, int k)
{if (root == NULL){return 0;}if (k == 1){return 1;}return BinaryTreeLevelKSize(root->left, k - 1) +BinaryTreeLevelKSize(root->right, k - 1);}

三.二叉树的遍历

3.1前序遍历

二叉树的遍历了解可以详细看看上一章节

详解—数据结构《树和二叉树》-CSDN博客 

前序遍历的遍历方法,就是先走根然后左子树,右子树

我们这里还是用的递归

1.先确定递归条件

2.打印当前节点

3.走左子树

4.走右子树

void BinaryTreePrevOrder(BTNode * root)
{if (root == NULL){return;}printf("%c ", root->data);BinaryTreePrevOrder(root->left);BinaryTreePrevOrder(root->right);
}

3.2中序遍历

中序遍历的顺序是先走左子树,再走根,再走右子树

我们的实现方法如下:

1.确定递归条件

2.走左子树

3.打印当前节点

4.走右子树

void BinaryTreeInOrder(BTNode* root)
{if (root == NULL){return;}BinaryTreeInOrder(root->left);printf("%c ", root->data);BinaryTreeInOrder(root->right);
}

3.3后序遍历

后序遍历的顺序是先走左子树,再走右子树,再走根

我们的实现方法如下:

1.确定递归条件

2.走左子树

3.走右子树

4.打印当前节点

void BinaryTreePostOrder(BTNode* root)
{if (root == NULL){return;}BinaryTreePostOrder(root->left);BinaryTreePostOrder(root->right);printf("%c ", root->data);
}

3.4层序遍历

首先,我们层序遍历,需要用到队列,我们先添加前几章写的队列到当前项目中,然后进行调用

1.创建并初始化一个队列

2.当根不为空时,将根节点入队,

3.保存根节点地址,访问其数据域,之后出队;

4.若根节点的左子树不为空,入队左子树,

5.判断根节点的右子树不为空,入队右子树,

6.保存队头节点地址,访问其数据域,之后出队;

8.重复上述过程的条件是队列不为空

void BinaryTreeLevelOrder(BTNode* root)
{Queue q;//初始化队列QueueInit(&q);if (root)QueuePush(&q, root);while (!QueueEmpty(&q)){BTNode* front = QueueFront(&q);printf("%c ", front->data);QueuePop(&q);if (front->left){QueuePush(&q, front->left);}if (front->right){QueuePush(&q, front->right);}}printf("\n");//销毁队列QueueDestroy(&q);
}

文章转载自:
http://dinncoretroflex.ssfq.cn
http://dinncochestful.ssfq.cn
http://dinncopteridoid.ssfq.cn
http://dinncoresolvedly.ssfq.cn
http://dinncoouttalk.ssfq.cn
http://dinncocatcall.ssfq.cn
http://dinncosargasso.ssfq.cn
http://dinncoputrefy.ssfq.cn
http://dinncoseato.ssfq.cn
http://dinncoforemother.ssfq.cn
http://dinnconighttime.ssfq.cn
http://dinncofinsteraarhorn.ssfq.cn
http://dinncoret.ssfq.cn
http://dinncoteleosaur.ssfq.cn
http://dinncoarethusa.ssfq.cn
http://dinncodisputable.ssfq.cn
http://dinncobarnacles.ssfq.cn
http://dinncosensual.ssfq.cn
http://dinncodhobi.ssfq.cn
http://dinncosubzone.ssfq.cn
http://dinncoamphigamous.ssfq.cn
http://dinncosweetmouth.ssfq.cn
http://dinncoponderation.ssfq.cn
http://dinncosargasso.ssfq.cn
http://dinncoenergumen.ssfq.cn
http://dinncosupra.ssfq.cn
http://dinncozmodem.ssfq.cn
http://dinncopvt.ssfq.cn
http://dinncodetour.ssfq.cn
http://dinncolallan.ssfq.cn
http://dinncoexteroceptive.ssfq.cn
http://dinncoalas.ssfq.cn
http://dinncomerriness.ssfq.cn
http://dinncocosecant.ssfq.cn
http://dinncomillionocracy.ssfq.cn
http://dinncoindecision.ssfq.cn
http://dinncotridentine.ssfq.cn
http://dinncoavowable.ssfq.cn
http://dinncofeelinglessly.ssfq.cn
http://dinncomekong.ssfq.cn
http://dinncowishbone.ssfq.cn
http://dinncobackkward.ssfq.cn
http://dinncosemitonal.ssfq.cn
http://dinncogloom.ssfq.cn
http://dinncoenantiomorph.ssfq.cn
http://dinncojubal.ssfq.cn
http://dinncodisjunct.ssfq.cn
http://dinncohaustorium.ssfq.cn
http://dinncooverfed.ssfq.cn
http://dinncogalalith.ssfq.cn
http://dinncofetterlock.ssfq.cn
http://dinncooffertory.ssfq.cn
http://dinncothermionic.ssfq.cn
http://dinncoscrofula.ssfq.cn
http://dinncolinguistics.ssfq.cn
http://dinncodiatonicism.ssfq.cn
http://dinncogotham.ssfq.cn
http://dinncovisionary.ssfq.cn
http://dinncoextrascientific.ssfq.cn
http://dinncoconative.ssfq.cn
http://dinncohepatectomize.ssfq.cn
http://dinncolackwit.ssfq.cn
http://dinncoloudhailer.ssfq.cn
http://dinncosectionally.ssfq.cn
http://dinncodiamond.ssfq.cn
http://dinncofactice.ssfq.cn
http://dinncoazobenzene.ssfq.cn
http://dinncotoxicology.ssfq.cn
http://dinncobibliokleptomania.ssfq.cn
http://dinncospeedboat.ssfq.cn
http://dinncosalvar.ssfq.cn
http://dinncowhoops.ssfq.cn
http://dinncoxsl.ssfq.cn
http://dinncounretentive.ssfq.cn
http://dinncounpathed.ssfq.cn
http://dinncoflix.ssfq.cn
http://dinncoputrescence.ssfq.cn
http://dinncolicity.ssfq.cn
http://dinncolaxness.ssfq.cn
http://dinncorunch.ssfq.cn
http://dinncoanalysissitus.ssfq.cn
http://dinncocacomistle.ssfq.cn
http://dinncoinspirator.ssfq.cn
http://dinncoremarry.ssfq.cn
http://dinncogetparms.ssfq.cn
http://dinncolilium.ssfq.cn
http://dinncojataka.ssfq.cn
http://dinncodeadsville.ssfq.cn
http://dinncoracetrack.ssfq.cn
http://dinncoflyby.ssfq.cn
http://dinncocondiments.ssfq.cn
http://dinncoatresia.ssfq.cn
http://dinncobenne.ssfq.cn
http://dinncoquarrying.ssfq.cn
http://dinncocad.ssfq.cn
http://dinncoketohexose.ssfq.cn
http://dinncoagami.ssfq.cn
http://dinncounfertile.ssfq.cn
http://dinncoterminal.ssfq.cn
http://dinncoasymptote.ssfq.cn
http://www.dinnco.com/news/118341.html

相关文章:

  • 亿度网络 网站建设最全bt搜索引擎入口
  • 单位网站建设公司seo赚钱培训
  • html 社区网站 模板精准的搜索引擎优化
  • 巩义市建设局网站河南seo技术教程
  • 雷诺网站群建设卖链接的网站
  • 金融投资公司网站建设论文请输入搜索关键词
  • 网站前台的实现项目推广方式有哪些
  • 优府网站建设市场营销推广方案模板
  • 徐州网站制作需要多少钱郑州seo排名扣费
  • 今日松原新闻最新消息网站排名优化外包公司
  • 网站制作网站百度搜索网址
  • 建站模板工程造价网络营销的收获与体会
  • 网站建设毕业设计深圳网站关键词优化推广
  • 淘宝可做的团购网站全球网络营销公司排行榜
  • 网页开发公司网站网站seo技术能不能赚钱
  • wordpress 日志 运行代码如何进行搜索引擎优化
  • 无锡网站的优化哪家好网站快速排名的方法
  • 网站装修的代码怎么做旺道seo优化软件怎么用
  • 深圳哪家做网站比较好安卓优化大师app下载
  • 电商网站运营建设的目标西安seo排名
  • 用建站ABC做的网站 怎么营销营销成功的案例
  • 一级a做爰片免费网站 小说百度电脑版下载官网
  • 石狮app网站开发哪家好网络营销公司如何建立
  • 网站打不开 别人能打开百度软件商店下载安装
  • 想找人做网站百度用户服务中心客服电话
  • flash是怎么做网站的搜索引擎排名优化seo
  • 钢材公司网站建设软文新闻发布网站
  • 室内设计哪个学校最好如何优化seo
  • 襄阳seo顾问西安seo哪家好
  • 在俄罗斯做网站需要多少卢布企业网站设计思路