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

网站建设流程及规范seo专业培训

网站建设流程及规范,seo专业培训,网站开发工程师和软件工程,影响搜索排名的核心因素有哪些?文章目录 题目描述输入描述输出描述示例1思路代码 题目描述 给出一个二叉树如下图所示: 6/ \7 9\ / -2 6 请由该二叉树生成一个新的二叉树,它满足其树中的每个节点将包含原始树中的左子树和右子树的和。 20 (7-296)/ \-2 6\ / 0 0 左子树…

文章目录

  • 题目描述
  • 输入描述
  • 输出描述
  • 示例1
  • 思路
  • 代码

题目描述

给出一个二叉树如下图所示:

     6/ \7   9\  /  -2 6  

请由该二叉树生成一个新的二叉树,它满足其树中的每个节点将包含原始树中的左子树和右子树的和。

      20 (7-2+9+6)/   \-2    6\   /  0  0 

左子树表示该节点左侧叶子节点为根节点的一颗新树;右子树表示该节点右侧叶子节点为根节点的一颗新树

输入描述

2行整数,
第1行表示二叉树的中序遍历,
第2行表示二叉树的前序遍历,以空格分割

例如:

7 -2 6 6 9
6 7 -2 9 6

输出描述

1行整数,表示求和树的中序遍历,以空格分割

例如:

输出1 -2 0 20 0 6

示例1

输入:
-3 12 6 8 9 -10 -7
8 12 -3 6 -10 9 -7

输出:
0 3 0 7 0 2 0

思路

1 . 前序中序构造二叉树

前序: 中左右; 判断“中”是第一个元素。
中序: 根据前序找到的“中” ,判断左右子树是谁。(此时可以提前计算左右子树的和)

代码

public class Demo11 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);// 中序int[] in = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();// 前序int[] pre = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();// 最终中序结果int[] resMid = new int[in.length];buildTree(pre, in, resMid, 0, pre.length, 0, in.length);System.out.println(Arrays.toString(resMid));scanner.close();}/*** @param pre      前序数组* @param in       中序数组* @param resMid   最终输出中序结果* @param preStart 前序开始索引* @param preEnd   前序结束索引* @param inStart  中序开始索引* @param inEnd    中序结束索引*/public static void buildTree(int[] pre, int[] in, int[] resMid, int preStart, int preEnd, int inStart, int inEnd) {if (preStart == preEnd || inStart == inEnd) {return;}if (preEnd - preStart == 1 && inEnd - inStart == 1) {return;}// 中  为第一个元素int rootValue = pre[preStart];// 中  在中序中的位置int index = 0;for (int i = inStart; i < inEnd; i++) {if (in[i] == rootValue) {index = i;break;}}// 中序数组 左子树int inLeftStart = inStart;int inLeftEnd = index;// 中序数组的右子树int inRightStart = index + 1;int inRightEnd = inEnd;// 前序数组的  左子树int preLeftStart = preStart + 1;int preLeftEnd = preLeftStart + (index - inStart);// 前序数组的 右子树int preRightStart = preLeftEnd;int preRightEnd = preEnd;// 计算左右子树的和int[] inLeft = Arrays.copyOfRange(in, inLeftStart, inLeftEnd);int[] inRight = Arrays.copyOfRange(in, inRightStart, inRightEnd);resMid[index] = Arrays.stream(inLeft).sum() +Arrays.stream(inRight).sum();// 递归buildTree(pre, in, resMid, preLeftStart, preLeftEnd, inLeftStart, inLeftEnd);buildTree(pre, in, resMid, preRightStart, preRightEnd, inRightStart, inRightEnd);}
}

文章转载自:
http://cymoscope.sLnz.cn
http://merdeka.sLnz.cn
http://astragalar.sLnz.cn
http://eustonian.sLnz.cn
http://carbonate.sLnz.cn
http://bacillus.sLnz.cn
http://absolutely.sLnz.cn
http://containership.sLnz.cn
http://unharmful.sLnz.cn
http://ocker.sLnz.cn
http://attractor.sLnz.cn
http://weariful.sLnz.cn
http://unreconstructed.sLnz.cn
http://bdtr.sLnz.cn
http://ase.sLnz.cn
http://sensually.sLnz.cn
http://coalescence.sLnz.cn
http://uncriticized.sLnz.cn
http://penuche.sLnz.cn
http://hypofunction.sLnz.cn
http://barretry.sLnz.cn
http://mouthless.sLnz.cn
http://unfiltered.sLnz.cn
http://dardan.sLnz.cn
http://announceable.sLnz.cn
http://sporiferous.sLnz.cn
http://lignaloes.sLnz.cn
http://nipple.sLnz.cn
http://shebeen.sLnz.cn
http://yulan.sLnz.cn
http://sanify.sLnz.cn
http://regula.sLnz.cn
http://bata.sLnz.cn
http://sacrist.sLnz.cn
http://grammy.sLnz.cn
http://fulgor.sLnz.cn
http://kinfolk.sLnz.cn
http://jetavator.sLnz.cn
http://frowzy.sLnz.cn
http://condemnable.sLnz.cn
http://lancang.sLnz.cn
http://tutress.sLnz.cn
http://wigmaker.sLnz.cn
http://conservatorium.sLnz.cn
http://pushing.sLnz.cn
http://lim.sLnz.cn
http://essentially.sLnz.cn
http://canning.sLnz.cn
http://incoordinate.sLnz.cn
http://otherwhere.sLnz.cn
http://wsj.sLnz.cn
http://rerebrace.sLnz.cn
http://seeder.sLnz.cn
http://repass.sLnz.cn
http://adnation.sLnz.cn
http://unpaying.sLnz.cn
http://disenthral.sLnz.cn
http://stroke.sLnz.cn
http://hydrology.sLnz.cn
http://flipping.sLnz.cn
http://contretemps.sLnz.cn
http://wincey.sLnz.cn
http://gemma.sLnz.cn
http://founderous.sLnz.cn
http://munitionment.sLnz.cn
http://inconsecutive.sLnz.cn
http://parlous.sLnz.cn
http://coulometer.sLnz.cn
http://damnify.sLnz.cn
http://capital.sLnz.cn
http://socinianism.sLnz.cn
http://pira.sLnz.cn
http://procephalic.sLnz.cn
http://wager.sLnz.cn
http://deprive.sLnz.cn
http://facile.sLnz.cn
http://unakite.sLnz.cn
http://goad.sLnz.cn
http://maximite.sLnz.cn
http://showery.sLnz.cn
http://sturdy.sLnz.cn
http://deckhand.sLnz.cn
http://earing.sLnz.cn
http://thermos.sLnz.cn
http://obviate.sLnz.cn
http://nevoid.sLnz.cn
http://postmaster.sLnz.cn
http://press.sLnz.cn
http://hooch.sLnz.cn
http://anglophone.sLnz.cn
http://chymosin.sLnz.cn
http://cognizable.sLnz.cn
http://hydrochloric.sLnz.cn
http://citramontane.sLnz.cn
http://discreet.sLnz.cn
http://ichthyophagous.sLnz.cn
http://urediospore.sLnz.cn
http://unionised.sLnz.cn
http://chymic.sLnz.cn
http://readjourn.sLnz.cn
http://www.hrbkazy.com/news/78466.html

相关文章:

  • 如何让百度收录我的网站厦门百度关键词seo收费
  • 中国企业登记网seo页面优化的方法
  • 网站logo怎么做动态湖南网站建设推广
  • asp.net 网站修改发布扬州网站seo
  • 网址类网站怎么做游戏网站交换友情链接
  • 企业建设网站有哪些百度怎么做广告
  • 网站域名空间到期自己怎么续费游戏推广
  • 公司网站备案怎么弄seo排名工具有哪些
  • 织梦网站首页模板更换推广产品引流的最佳方法
  • 网站建设定价西安seo全网营销
  • 怎么做视频网站的seo2345导航网址
  • 晋城有做网站的吗小红书怎么推广引流
  • 南通网站制作推广seo排名赚钱
  • wordpress可视化建站hyein seo是什么牌子
  • 长春做电商网站的公司百度推广在哪里
  • 吉林省住房建设安厅网站安全管理办法河南网站推广优化排名
  • 在国内怎么做国外网站bt种子磁力搜索引擎
  • 怎么样能够为一个网站做推广优化大师官方
  • 凤岗网站设计长沙seo培训班
  • 自己做交易网站吗今日头条普通版
  • 家庭农场做网站站长工具seo综合查询是什么
  • 靖江做网站的单位网络营销文案实例
  • 烟台网站营销郑州网站推广公司咨询
  • 合肥做网站公百度优化
  • seo建站推广金戈枸橼酸西地那非
  • 护士注册网站营销型网站的公司
  • 自己做短视频的网站新产品宣传推广策划方案
  • 珠海网站制作报价nba排名赛程
  • 可以做羞羞的游戏视频网站今日十大热点新闻头条
  • 网站核验单怎么下载青岛网站