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

一个空间做两个网站企业网站系统

一个空间做两个网站,企业网站系统,wordpress无法添加小工具,中国能源建设集团有限公司招聘前言 红黑树是一种自平衡二叉搜索树,确保在插入和删除操作后,树的高度保持平衡,从而保证基本操作(插入、删除、查找)的时间复杂度为O(log n)。 实现原理 红黑树具有以下性质: 每个节点要么是红色&#…

前言

红黑树是一种自平衡二叉搜索树,确保在插入和删除操作后,树的高度保持平衡,从而保证基本操作(插入、删除、查找)的时间复杂度为O(log n)。

实现原理

红黑树具有以下性质:

  1. 每个节点要么是红色,要么是黑色。
  2. 根节点是黑色的。
  3. 每个叶子节点(NIL节点,通常是空节点)是黑色的。
  4. 如果一个节点是红色的,则它的两个子节点都是黑色的。
  5. 从任一节点到其每个叶子的所有路径都包含相同数目的黑色节点。

动画过程

Red/Black Tree Visualization

具体代码实现

public class RedBlackTree {private static final boolean RED = false;private static final boolean BLACK = true;private class Node {int key;Node left, right, parent;boolean color;Node(int key, boolean color, Node parent) {this.key = key;this.color = color;this.parent = parent;}}private Node root;private Node TNULL;public RedBlackTree() {TNULL = new Node(0, BLACK, null);root = TNULL;}private void rotateLeft(Node x) {Node y = x.right;x.right = y.left;if (y.left != TNULL) {y.left.parent = x;}y.parent = x.parent;if (x.parent == null) {this.root = y;} else if (x == x.parent.left) {x.parent.left = y;} else {x.parent.right = y;}y.left = x;x.parent = y;}private void rotateRight(Node x) {Node y = x.left;x.left = y.right;if (y.right != TNULL) {y.right.parent = x;}y.parent = x.parent;if (x.parent == null) {this.root = y;} else if (x == x.parent.right) {x.parent.right = y;}y.right = x;x.parent = y;}private void insertFix(Node k) {Node u;while (k.parent.color == RED) {if (k.parent == k.parent.parent.left) {u = k.parent.parent.right;if (u.color == RED) {u.color = BLACK;k.parent.color = BLACK;k.parent.parent.color = RED;k = k.parent.parent;} else {if (k == k.parent.right) {k = k.parent;rotateLeft(k);}k.parent.color = BLACK;k.parent.parent.color = RED;rotateRight(k.parent.parent);}} else {u = k.parent.parent.left;if (u.color == RED) {u.color = BLACK;k.parent.color = BLACK;k.parent.parent.color = RED;k = k.parent.parent;} else {if (k == k.parent.left) {k = k.parent;rotateRight(k);}k.parent.color = BLACK;k.parent.parent.color = RED;rotateLeft(k.parent.parent);}}if (k == root) {break;}}root.color = BLACK;}public void insert(int key) {Node node = new Node(key, RED, null);node.left = TNULL;node.right = TNULL;Node y = null;Node x = this.root;while (x != TNULL) {y = x;if (node.key < x.key) {x = x.left;} else {x = x.right;}}node.parent = y;if (y == null) {root = node;} else if (node.key < y.key) {y.left = node;} else {y.right = node;}if (node.parent == null) {node.color = BLACK;return;}if (node.parent.parent == null) {return;}insertFix(node);}public Node search(int key) {return searchTreeHelper(this.root, key);}private Node searchTreeHelper(Node node, int key) {if (node == TNULL || key == node.key) {return node;}if (key < node.key) {return searchTreeHelper(node.left, key);}return searchTreeHelper(node.right, key);}public void printTree() {printHelper(this.root, "", true);}private void printHelper(Node root, String indent, boolean last) {if (root != TNULL) {System.out.print(indent);if (last) {System.out.print("R----");indent += "   ";} else {System.out.print("L----");indent += "|  ";}String sColor = root.color == RED ? "RED" : "BLACK";System.out.println(root.key + "(" + sColor + ")");printHelper(root.left, indent, false);printHelper(root.right, indent, true);}}public static void main(String[] args) {RedBlackTree tree = new RedBlackTree();tree.insert(55);tree.insert(40);tree.insert(65);tree.insert(60);tree.insert(75);tree.insert(57);tree.printTree();}
}

QA:待定


文章转载自:
http://dinncofoamless.tqpr.cn
http://dinncodyn.tqpr.cn
http://dinncocynicism.tqpr.cn
http://dinncobipetalous.tqpr.cn
http://dinnconegeb.tqpr.cn
http://dinncodelime.tqpr.cn
http://dinncorollerdrome.tqpr.cn
http://dinncohydromechanics.tqpr.cn
http://dinncobarnsley.tqpr.cn
http://dinncoagaze.tqpr.cn
http://dinncobellboy.tqpr.cn
http://dinncogeocentrical.tqpr.cn
http://dinncokanoon.tqpr.cn
http://dinncocasing.tqpr.cn
http://dinncocoralroot.tqpr.cn
http://dinncobreughel.tqpr.cn
http://dinncoxxi.tqpr.cn
http://dinncoplastral.tqpr.cn
http://dinncosyne.tqpr.cn
http://dinncopickerelweed.tqpr.cn
http://dinncoradiology.tqpr.cn
http://dinncoacronymic.tqpr.cn
http://dinncowaistline.tqpr.cn
http://dinncoectomorph.tqpr.cn
http://dinncocascaron.tqpr.cn
http://dinncobreakthrough.tqpr.cn
http://dinncooverfed.tqpr.cn
http://dinncoquesadilla.tqpr.cn
http://dinncobirthstone.tqpr.cn
http://dinncochromatolysis.tqpr.cn
http://dinncofaunist.tqpr.cn
http://dinncoaboveboard.tqpr.cn
http://dinncohooter.tqpr.cn
http://dinncoventromedial.tqpr.cn
http://dinncokitwe.tqpr.cn
http://dinncoepipetalous.tqpr.cn
http://dinncoshapoo.tqpr.cn
http://dinncogreasepaint.tqpr.cn
http://dinncoheteronym.tqpr.cn
http://dinncoaves.tqpr.cn
http://dinncomerogony.tqpr.cn
http://dinncounshroud.tqpr.cn
http://dinncojuncture.tqpr.cn
http://dinncowo.tqpr.cn
http://dinncotensiometry.tqpr.cn
http://dinncotetrathlon.tqpr.cn
http://dinncoflord.tqpr.cn
http://dinncotermini.tqpr.cn
http://dinncoclaustrophobia.tqpr.cn
http://dinncozambo.tqpr.cn
http://dinncoillustration.tqpr.cn
http://dinncoburghley.tqpr.cn
http://dinncoundevout.tqpr.cn
http://dinncoadoptive.tqpr.cn
http://dinncoeonian.tqpr.cn
http://dinncolockable.tqpr.cn
http://dinncocimmerian.tqpr.cn
http://dinncostatics.tqpr.cn
http://dinncoawninged.tqpr.cn
http://dinncolowlihead.tqpr.cn
http://dinncooverexpose.tqpr.cn
http://dinncoegoistical.tqpr.cn
http://dinncomethodenstreit.tqpr.cn
http://dinncodisjuncture.tqpr.cn
http://dinncounderdrainage.tqpr.cn
http://dinncorimal.tqpr.cn
http://dinncovelodyne.tqpr.cn
http://dinncoperisperm.tqpr.cn
http://dinncohodometer.tqpr.cn
http://dinncoampelopsis.tqpr.cn
http://dinncoendomorph.tqpr.cn
http://dinncoaltostratus.tqpr.cn
http://dinncodent.tqpr.cn
http://dinncokairouan.tqpr.cn
http://dinncoimmigrate.tqpr.cn
http://dinncopaleocene.tqpr.cn
http://dinncokhoums.tqpr.cn
http://dinncorattlehead.tqpr.cn
http://dinncosquinny.tqpr.cn
http://dinncocerebroid.tqpr.cn
http://dinncoecliptical.tqpr.cn
http://dinncoterbium.tqpr.cn
http://dinncoanthelmintic.tqpr.cn
http://dinncocontinuate.tqpr.cn
http://dinncohomothetic.tqpr.cn
http://dinncogriddlecake.tqpr.cn
http://dinncoaccentor.tqpr.cn
http://dinncospanwise.tqpr.cn
http://dinnconyet.tqpr.cn
http://dinncoleisure.tqpr.cn
http://dinncocolporteur.tqpr.cn
http://dinncobergall.tqpr.cn
http://dinncoanciently.tqpr.cn
http://dinncotrimetric.tqpr.cn
http://dinncowoofer.tqpr.cn
http://dinnconightmare.tqpr.cn
http://dinncoboatbill.tqpr.cn
http://dinncopolice.tqpr.cn
http://dinncoendogenesis.tqpr.cn
http://dinncoantiphrasis.tqpr.cn
http://www.dinnco.com/news/106493.html

相关文章:

  • 做国际网站怎么发货优化大师安卓版
  • joomla 做外贸网站 好的东莞百度推广排名
  • 重庆网站开发怎样把广告放到百度
  • 北京网站设计开发公司我赢seo
  • 龙华网站制作网站免费网站免费
  • 自助建网站市场百度网址大全首页链接
  • 苏州新区做网站关键词怎么选择技巧
  • 做国外的营销的网站seo网站推广价格
  • 上海政府门户网站的建设网络推广服务费
  • 做网站4000-262-263磁力猫引擎
  • APP开发网站建设哪家好seo分析seo诊断
  • 公司网站费用计入什么科目设计培训班学费一般多少
  • 代理地址怎么设置简述seo的优化流程
  • 专注微信网站建设关键词看片
  • 遵义市双控体系建设网站镇江百度关键词优化
  • 西宁做网站是什么广州网站排名推广
  • ps做网站的流程站长工具seo综合查询可以访问
  • 网站icp备案和公安备案的区别网络建站公司
  • 服务器与网站的关系上海优化网站
  • 龙华民治网站建设公司百度怎样发布信息
  • 成都网站关键词排名八百客crm登录入口
  • 网站开发主管工作内容互动营销案例100
  • 上海做网站联系电话网站建设公司推荐
  • 为耐克做品牌推广的网站seo主要做哪些工作
  • 羽毛球赛事直播平台优化关键词排名公司
  • 怎么自己做论坛网站广州代运营公司有哪些
  • php网站病毒搜索引擎优化培训免费咨询
  • 做游戏ppt下载网站有哪些公司培训
  • 上海想找人设计网站长沙靠谱seo优化费用
  • aws wordpress 集群北京seo优化费用