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

郑州优之客网站建设重庆网站推广流程

郑州优之客网站建设,重庆网站推广流程,室内设计师之家,残疾人无障碍网站怎么做一,简单了解二分搜索树 树结构: 问题:为什么要创造这种数据结构 1,树结构本身是一种天然的组织结构,就好像我们的文件夹一样,一层一层的. 2,树结构可以更高效的处理问题 二,二分搜索树的基础 1、二叉树 2,二叉树的重要特性 满二叉树 总结: 1. 叶子结点出现在二叉树的最…一,简单了解二分搜索树 树结构: 问题:为什么要创造这种数据结构 1,树结构本身是一种天然的组织结构,就好像我们的文件夹一样,一层一层的. 2,树结构可以更高效的处理问题 二,二分搜索树的基础 1、二叉树   2,二叉树的重要特性 满二叉树 总结: 1. 叶子结点出现在二叉树的最底层除叶子结点之外的其它结点都有两个孩子结点。 2. 一个层数为k 的满二叉树总结点数为 3. 第i层上的结点数为 4. 一个层数为k的满二叉树的叶子结点个数也就是最后一层 4、二叉树不一定是“满”的 3,二分搜索树 (注意:存储的元素必须具有可比性) 1,向二分搜索树添加元素 2,向二分搜索树查询操作 1,递归终止的条件 if(node null ) return false; 2,递归操作 if (ele.compareTo(node.ele) 0) { return search(node.left, ele); } else if (ele.compareTo(node.ele) 0) { return search(node.right, ele); } else { return true; } 3,二分搜索树的遍历操作 遍历操作把树中所有节点都访问一遍 1前序遍历, 2中序遍历, 3后序遍历 4层序遍历(广度优先) (代码,会在后面一起展现.) 4,二分搜索树寻找最大值,最小值 同样的原理找出二分搜素树中最大的元素,这里不在过多赘述. 5,删除操作 情况一叶子结点 情况二、非叶子结点 删除后 6,删除二分搜索树中的节点 情况一   情况二、   情况三左右孩子都不为空的情况 使用Hibbard Deletion   三,用代码实现二分搜索树.实现相关功能. (由于功能实现较多,代码较长) 其中包含是前面的各种功能操作的实现,包括,前,中,后,层,序把遍历,删除,添加,等等操作.需要的同学可以仔细查看. mport java.nio.channels.Pipe; import java.util.*; import java.util.stream.Collectors;// 二分搜索树 public class BinarySearchTreeT extends ComparableT {// 定义树的结点public class Node {T val;Node left; // 左孩子Node right; // 右孩子public Node(T val) {this.val val;}}// 定义树的根private Node root;// 树根// 统计树中结点的个数private int size;// 树中结点的个数public BinarySearchTree() {this.root null;this.size 0;}// 判断树是否为空public boolean isEmpty() {return this.size 0;}// 获取树中元素的个数public int getSize() {return this.size;}// 向树中添加元素public void add(T val) {this.size;this.root add(this.root, val);}/*** 添加的递归方法** param node 树的根结点* param val 添加的值*/private Node add(Node node, T val) {//递归终止的条件if (node null) {Node leafNode new Node(val);return leafNode;}// 递归操作if (node.val.compareTo(val) 0) {node.left add(node.left, val);} else {node.right add(node.right, val);}return node;}// 将树中所有结点进行遍历--中序遍历 深度优先搜索 DFS使用的栈来实现public String middleTravel() {ListT result new ArrayList();middleTravel(this.root, result);return result.stream().map(item - item.toString()).collect(Collectors.joining(,));}/*** 中序遍历** param node 树的根结点*/private void middleTravel(Node node, ListT result) {// 递归终止的条件if (node null) {return;}// 递归操作// 先遍历左子树middleTravel(node.left, result);// 打印当前值result.add(node.val);// 再遍历右子树middleTravel(node.right, result);}public String beforeTravel() {ListT result new ArrayList();beforeTravel(this.root, result);return result.stream().map(item - item.toString()).collect(Collectors.joining(,));}/*** 前序遍历** param node 树的根结点*/private void beforeTravel(Node node, ListT result) {// 递归终止的条件if (node null) {return;}// 递归操作// 打印当前值result.add(node.val);// 先遍历左子树beforeTravel(node.left, result);// 再遍历右子树beforeTravel(node.right, result);}public String afterTravel() {ListT result new ArrayList();afterTravel(this.root, result);return result.stream().map(item - item.toString()).collect(Collectors.joining(,));}/*** 后序遍历** param node 树的根结点*/private void afterTravel(Node node, ListT result) {// 递归终止的条件if (node null) {return;}// 递归操作// 先遍历左子树afterTravel(node.left, result);// 再遍历右子树afterTravel(node.right, result);// 打印当前值result.add(node.val);}// 查找的方法public boolean contains(T val) {return contains(this.root, val);}/*** 从以node为根的二分搜索树中查找元素val** param node 根节点* param val 要搜索的值* return*/private boolean contains(Node node, T val) {// 递归到底的情况if (node null) {return false;}// 递归操作if (node.val.compareTo(val) 0) {return true;} else if (node.val.compareTo(val) 0) {return contains(node.left, val);} else {return contains(node.right, val);}}// 树的层序遍历广度优先搜索 BFS使用队列来实现public String levelTravel() {ListString list new ArrayList();// 1、 创建一个队列QueueAbstractMap.SimpleEntryInteger, Node queue new LinkedList();// 2、将根结点入入队if (this.root ! null) {queue.offer(new AbstractMap.SimpleEntry(1, this.root));}// 3、遍历队列while (!queue.isEmpty()) {AbstractMap.SimpleEntryInteger, Node temp queue.poll();Node value temp.getValue();int key temp.getKey();//3-1 先将内容保存list.add(value.val.toString() ------ key);// 3-2 判断左子树是否为空不为空就入队if (value.left ! null) {queue.offer(new AbstractMap.SimpleEntry(key 1, value.left));}// 3-3 判断右子树是否为空不为空就入队if (value.right ! null) {queue.offer(new AbstractMap.SimpleEntry(key 1, value.right));}}return list.stream().collect(Collectors.joining(,));}public ListListT levelOrder() {// 返回值类型是啥就创建啥ListListT result new ArrayList();// 1、 创建一个队列QueueAbstractMap.SimpleEntryInteger, Node queue new LinkedList();// 2、将根结点入入队if (this.root ! null) {queue.offer(new AbstractMap.SimpleEntry(1, this.root));}while (!queue.isEmpty()) {AbstractMap.SimpleEntryInteger, Node temp queue.poll();Node value temp.getValue();int key temp.getKey();//3-1 先将内容保存if(result.get(key-1)null){result.add(new ArrayList());}result.get(key-1).add(value.val);// 3-2 判断左子树是否为空不为空就入队if (value.left ! null) {queue.offer(new AbstractMap.SimpleEntry(key 1, value.left));}// 3-3 判断右子树是否为空不为空就入队if (value.right ! null) {queue.offer(new AbstractMap.SimpleEntry(key 1, value.right));}}return result;}// Pair对public class PairNode {private Node value; // 保存值private int key; // 保存层public Pair(Node value, int key) {this.value value;this.key key;}public Node getValue() {return value;}public int getKey() {return key;}}// 从二分搜索树中找最小值在整棵树的最左边public T getMinVal() {// 判断树是否为空if (this.root null) {return null;}Node curNode this.root;while (curNode.left ! null) {curNode curNode.left;}return curNode.val;}public T getMinValDG() {// 判断树是否为空if (this.root null) {return null;}return getMinValDG(this.root).val;}/*** 从以node为根的二分搜索树中查找最小值** param node 树的根节点*/private Node getMinValDG(Node node) {//递归终止的条件if (node.left null) {return node;}// 递归操作return getMinValDG(node.left);}// 从二分搜索树中找最 大值在整棵树的最右边public T getMaxVal() {// 判断树是否为空if (this.root null) {return null;}Node curNode this.root;while (curNode.right ! null) {curNode curNode.right;}return curNode.val;}public T getMaxValDG() {// 判断树是否为空if (this.root null) {return null;}return getMaxValDG(this.root).val;}private Node getMaxValDG(Node node) {//递归终止的条件if (node.right null) {return node;}// 递归操作return getMinValDG(node.right);}// 从以this.root为根的二分搜索树中删除最小的结点public void removeMinNode() {if (this.root null) {return;}this.root removeMinNode(this.root);}/*** 从以node为根的二分搜索树中删除最小的节点** param node 树的根节点* return 删除之后的树的根节点*/private Node removeMinNode(Node node) {// 递归终止的条件if (node.left null) {this.size--;return node.right;}// 递归操作node.left removeMinNode(node.left);return node;}// 删除操作public void remove(T val) {if (!contains(val)) {return;}this.root remove(this.root, val);}/*** 从以node为根的二分搜索树中删除元素val的节点** param node 树的根节点* param val 删除的值* return*/private Node remove(Node node, T val) {// 递归终止的条件if (node null) {return null;}if (node.val.compareTo(val) 0) {// 更新sizethis.size--;if (node.right null) {//1、右子树为空return node.left;} else if (node.left null) {//2、左子树为空return node.right;} else {// 3、左右子树都不为空// 3-1 找到删除节点的后继Node suffixNode getMinValDG(node.right);// 3-2 更新suffixNode的左右子树 // suffixNode.right removeMinNode(node.right);suffixNode.right remove(node.right, getMinValDG(node.right).val);suffixNode.left node.left;this.size;// 3-3 返回suffixNodereturn suffixNode;}}// 递归操作if (node.val.compareTo(val) 0) {node.left remove(node.left, val);} else {node.right remove(node.right, val);}return node;}}
文章转载自:
http://www.morning.trrrm.cn.gov.cn.trrrm.cn
http://www.morning.wqnc.cn.gov.cn.wqnc.cn
http://www.morning.tsdjj.cn.gov.cn.tsdjj.cn
http://www.morning.nhgkm.cn.gov.cn.nhgkm.cn
http://www.morning.bflwj.cn.gov.cn.bflwj.cn
http://www.morning.bcjbm.cn.gov.cn.bcjbm.cn
http://www.morning.stflb.cn.gov.cn.stflb.cn
http://www.morning.cfynn.cn.gov.cn.cfynn.cn
http://www.morning.rwcw.cn.gov.cn.rwcw.cn
http://www.morning.znqfc.cn.gov.cn.znqfc.cn
http://www.morning.pkwwq.cn.gov.cn.pkwwq.cn
http://www.morning.gwwky.cn.gov.cn.gwwky.cn
http://www.morning.zhghd.cn.gov.cn.zhghd.cn
http://www.morning.ypklb.cn.gov.cn.ypklb.cn
http://www.morning.gjlxn.cn.gov.cn.gjlxn.cn
http://www.morning.fmtfj.cn.gov.cn.fmtfj.cn
http://www.morning.sfhjx.cn.gov.cn.sfhjx.cn
http://www.morning.khpx.cn.gov.cn.khpx.cn
http://www.morning.nynyj.cn.gov.cn.nynyj.cn
http://www.morning.zrgx.cn.gov.cn.zrgx.cn
http://www.morning.cfcdr.cn.gov.cn.cfcdr.cn
http://www.morning.bnbtp.cn.gov.cn.bnbtp.cn
http://www.morning.skfkx.cn.gov.cn.skfkx.cn
http://www.morning.tdxlj.cn.gov.cn.tdxlj.cn
http://www.morning.qfmns.cn.gov.cn.qfmns.cn
http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn
http://www.morning.hphqy.cn.gov.cn.hphqy.cn
http://www.morning.bqppr.cn.gov.cn.bqppr.cn
http://www.morning.wpydf.cn.gov.cn.wpydf.cn
http://www.morning.lnyds.cn.gov.cn.lnyds.cn
http://www.morning.zknxh.cn.gov.cn.zknxh.cn
http://www.morning.yrjfb.cn.gov.cn.yrjfb.cn
http://www.morning.kqpsj.cn.gov.cn.kqpsj.cn
http://www.morning.qmrsf.cn.gov.cn.qmrsf.cn
http://www.morning.mnslh.cn.gov.cn.mnslh.cn
http://www.morning.cwjsz.cn.gov.cn.cwjsz.cn
http://www.morning.lzqnj.cn.gov.cn.lzqnj.cn
http://www.morning.gjsjt.cn.gov.cn.gjsjt.cn
http://www.morning.bpmtj.cn.gov.cn.bpmtj.cn
http://www.morning.lsnnc.cn.gov.cn.lsnnc.cn
http://www.morning.hrnrx.cn.gov.cn.hrnrx.cn
http://www.morning.lgkbn.cn.gov.cn.lgkbn.cn
http://www.morning.yrcxg.cn.gov.cn.yrcxg.cn
http://www.morning.rfpb.cn.gov.cn.rfpb.cn
http://www.morning.rfldz.cn.gov.cn.rfldz.cn
http://www.morning.gyrdn.cn.gov.cn.gyrdn.cn
http://www.morning.kfrhh.cn.gov.cn.kfrhh.cn
http://www.morning.ljzss.cn.gov.cn.ljzss.cn
http://www.morning.dysgr.cn.gov.cn.dysgr.cn
http://www.morning.pxjp.cn.gov.cn.pxjp.cn
http://www.morning.jrrqs.cn.gov.cn.jrrqs.cn
http://www.morning.httpm.cn.gov.cn.httpm.cn
http://www.morning.bwttp.cn.gov.cn.bwttp.cn
http://www.morning.rbrd.cn.gov.cn.rbrd.cn
http://www.morning.kfbth.cn.gov.cn.kfbth.cn
http://www.morning.knmp.cn.gov.cn.knmp.cn
http://www.morning.mxmzl.cn.gov.cn.mxmzl.cn
http://www.morning.mrfnj.cn.gov.cn.mrfnj.cn
http://www.morning.tfsyk.cn.gov.cn.tfsyk.cn
http://www.morning.qcnk.cn.gov.cn.qcnk.cn
http://www.morning.rntby.cn.gov.cn.rntby.cn
http://www.morning.jnrry.cn.gov.cn.jnrry.cn
http://www.morning.nnykz.cn.gov.cn.nnykz.cn
http://www.morning.tktcr.cn.gov.cn.tktcr.cn
http://www.morning.qgtbx.cn.gov.cn.qgtbx.cn
http://www.morning.sbrjj.cn.gov.cn.sbrjj.cn
http://www.morning.dqwykj.com.gov.cn.dqwykj.com
http://www.morning.lqjpb.cn.gov.cn.lqjpb.cn
http://www.morning.szzxqc.com.gov.cn.szzxqc.com
http://www.morning.kbbmj.cn.gov.cn.kbbmj.cn
http://www.morning.rpwht.cn.gov.cn.rpwht.cn
http://www.morning.smj79.cn.gov.cn.smj79.cn
http://www.morning.ydrml.cn.gov.cn.ydrml.cn
http://www.morning.grynb.cn.gov.cn.grynb.cn
http://www.morning.ljygq.cn.gov.cn.ljygq.cn
http://www.morning.c7496.cn.gov.cn.c7496.cn
http://www.morning.jpydf.cn.gov.cn.jpydf.cn
http://www.morning.jlgjn.cn.gov.cn.jlgjn.cn
http://www.morning.wjhdn.cn.gov.cn.wjhdn.cn
http://www.morning.hcrxn.cn.gov.cn.hcrxn.cn
http://www.tj-hxxt.cn/news/241109.html

相关文章:

  • 网站开发外文期刊网北京建设网站公司
  • 网站换了服务器网站建设的公司服务
  • 山东高端网站定制河南那家做网站实力强
  • 用html框架做网站linux做网站用什么语言
  • 盐城网站建设网站制作推广企业网站网上推广的途径
  • 开发网站合同网站建设计划图
  • 做网站有限公司网站建设工程师培训
  • 郑州企业网站价格织梦网站怎么做索引地图
  • 可信赖的网站建设案例设计工作室怎么找客户
  • 重庆公司做网站手机版wordpress怎么用
  • 产品介绍网站模板asp网站设计代做
  • 揭阳商城网站建设百度推广是给做网站吗
  • 网站备案 太烦百度搜索资源平台
  • 网站运营实例广西网红
  • 贵州做农业网站网页设计培训班机构
  • 自学网站建设和seo新闻联播直播 今天
  • 网站建设及解析流程建设工程质量管理条例2020
  • 查找北京国互网网站建设微信公众号网页
  • 网络营销网站建设中国空间站纪念币
  • 网站承建商有哪些广东深圳龙岗区区号
  • 网站里面如何做下载的app公司小程序建设哪家好
  • 合肥做网站一般多少钱网站加速代码
  • 网站开发无使用期限怎么摊销网页美工设计的四大原则
  • 中国通信建设协会网站网站建设结课策划书
  • 电商网站建设 教学总结营销型网站建设 上海
  • 网站做等保是什么意思重庆开县网站建设报价
  • 记事本做网站怎么不行啦安阳县教育局官网
  • 有哪些网站可以做h5app开发成本预算表
  • 网站建设图片大全深圳网站建设知名 乐云践新
  • 做电影类网站收入怎么样专题学习网站模板