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

建一个免费网站百度推广怎么弄

建一个免费网站,百度推广怎么弄,网站开发网络公,网站建设基本话术1.初始化数组 //Initialize arrays.int tempLength getNumNodes();valuesArray new char[tempLength];indicesArray new int[tempLength];int i 0;2.初始化队列 创建了一个名为tempQueue的CircleObjectQueue对象,即一个循环对象队列。 将当前对象(即…

1.初始化数组

    //Initialize arrays.int tempLength = getNumNodes();valuesArray = new char[tempLength];indicesArray = new int[tempLength];int i = 0;

2.初始化队列

创建了一个名为tempQueue的CircleObjectQueue对象,即一个循环对象队列。
将当前对象(即this所指向的对象)入队到tempQueue队列尾部。

    //Traverse and convert at the same time.CircleObjectQueue tempQueue = new CircleObjectQueue();tempQueue.enqueue(this);

创建了另一个名为tempIntQueue的CircleObjectQueue对象,即又一个循环对象队列。
创建了一个Integer对象tempIndexInteger,其值为0。这里使用了Integer.valueOf方法来获取一个值为0的Integer对象,而不是直接使用基本数据类型int,可能是因为队列中需要存储的是对象。
将tempIndexInteger对象加入到tempIntQueue队列中。

    CircleObjectQueue tempIntQueue = new CircleObjectQueue();Integer tempIndexInteger = Integer.valueOf(0);tempIntQueue.enqueue(tempIndexInteger);

什么是Integer.valueOf方法?Integer.valueOf 是 Java 中 Integer 类的一个静态方法,用于将一个 int 值或 String 对象转换为 Integer 对象。
什么是表示该 int 值的 Integer 对象?通过Integer类将一个基本数据类型int的值封装成一个对象。在Java中,int是基本数据类型,而Integer是对应的包装类。包装类Integer提供了将int值转换为对象的能力,这样就可以在需要对象的上下文中使用int值。

3.层次遍历

从队列中取出BinaryCharTree对象

BinaryCharTree tempTree = (BinaryCharTree) tempQueue.dequeue();

tempIntQueue是一个队列,存储了Integer对象。
dequeue方法从队列中取出一个元素,并返回该元素。
((Integer) tempIntQueue.dequeue())是一个类型转换操作,将从队列中取出的对象转换为Integer类型。
intValue()方法将Integer对象转换为基本数据类型int。

int tempIndex = ((Integer) tempIntQueue.dequeue()).intValue();

打印tempIndex的值,遍历tempTree并存储数据到数组中

    System.out.println("tempIndex = " + tempIndex);while (tempTree != null) {valuesArray[i] = tempTree.value;indicesArray[i] = tempIndex;i++;

检查 tempTree 的左子节点是否为空,如果tempTree的左子节点不为null,则将左子节点加入到tempQueue队列中。同时,将左子节点的索引值tempIndex * 2 + 1加入到tempIntQueue队列中。这里的索引值计算方式是基于二叉树的层次遍历索引,假设根节点的索引为0,左子节点的索引为2 * 父节点索引 + 1。
右子节点同上。

if (tempTree.leftChild != null) {tempQueue.enqueue(tempTree.leftChild);tempIntQueue.enqueue(Integer.valueOf(tempIndex * 2 + 1));} // Of ifif (tempTree.rightChild != null) {tempQueue.enqueue(tempTree.rightChild);tempIntQueue.enqueue(Integer.valueOf(tempIndex * 2 + 2));} // Of if

从队列中取出一个BinaryCharTree对象,并检查该对象是否为null。如果为null,则跳出当前的循环。该操作用于避免空指针异常。

tempTree = (BinaryCharTree) tempQueue.dequeue();if (tempTree == null) {break;

4.main函数

构造二叉树,进行前序遍历、中序遍历、后序遍历并计算树的深度和节点数。

public static void main(String args[]) {BinaryCharTree tempTree = manualConstructTree();System.out.println("\r\nPreorder visit:");tempTree.preOrderVisit();System.out.println("\r\nIn-order visit:");tempTree.inOrderVisit();System.out.println("\r\nPost-order visit:");tempTree.PostOrderVisit();System.out.println("\r\n\r\nThe depth is: " + tempTree.getDepth());System.out.println("The number of nodes is: " + tempTree.getNumNodes());

将树的数据存储到数组中

    tempTree.toDataArrays();System.out.println("The values are: " + Arrays.toString(tempTree.valuesArray));System.out.println("The indices are: " + Arrays.toString(tempTree.indicesArray));

将树的数据存储到数组中

    tempTree.toDataArraysObjectQueue();System.out.println("Only object queue.");System.out.println("The values are: " + Arrays.toString(tempTree.valuesArray));System.out.println("The indices are: " + Arrays.toString(tempTree.indicesArray));

5.运行结果

Preorder visit:
a b d f g c e
In-order visit:
b f d g a e c
Post-order visit:
f g d b e c a

The depth is: 4
The number of nodes is: 7
No element in the queue
The values are: [a, b, c, d, e, f, g]
The indices are: [0, 1, 2, 4, 5, 9, 10]
tempIndex = 0
Only object queue.
The values are: [a, b, c, d, e, f, g]
The indices are: [0, 1, 2, 4, 5, 9, 10]

注意

main要包含在class类中
今天运行的过程中报错,原因是main函数放在了最外层class的花括号外。

http://www.fp688.cn/news/145560.html

相关文章:

  • 简述网站开发的基本流程seo的优点
  • 企业网站建设管理系统软件开发培训班
  • 诸城网站做的好的seo还可以做哪些推广
  • 苏州相城区最新通告郑州网站建设推广优化
  • 您身边的网站建设专家沈阳seo关键词排名优化软件
  • 上海最靠谱的网站建设google免费入口
  • 黄冈crm系统优化关键词的方法正确的是
  • 新疆建设监理协会网站深圳新闻今日最新
  • 厦门做网站最好的公司有哪些seo 视频
  • 有交做拼多多网站的吗网络营销渠道有哪三类
  • 一个服务器能放多少网站营销策划方案模板
  • 学校门户网站建设费用网页优化方法
  • 网站建设如何做好整体色彩搭配seo是什么意思如何实现
  • 做网站低价黑龙江网络推广好做吗
  • 石家庄网站建设刘华百度一下搜索网页
  • 住房建设网站武汉关键词包年推广
  • 北京漫步云端网站建设提升关键词排名软件哪家好
  • 清城区做模板网站建设最新新闻事件今天
  • 山东平阴疫情最新消息seo排名怎么优化软件
  • 官方网站下载免费软件百度投放平台
  • 怎么在自己的网站加关键词搜索引擎优化的基本方法
  • 网站访问者qq腾讯云域名
  • 潍坊网站建设 58搜狗收录批量查询
  • 电影网站如何做不侵权优化关键词具体要怎么做
  • 集团网站建设哪家更好全媒体广告加盟
  • 广州网站开发哪家好写软文平台
  • 专门做配电箱的网站推广平台 赚佣金
  • 举报网站建设情况总结百度的特点和优势
  • 哪建设网站好河南郑州最新消息今天
  • 网站客服漂浮广告代码佛山网站快速排名提升