{"id":2216,"date":"2022-08-08T12:35:46","date_gmt":"2022-08-08T04:35:46","guid":{"rendered":"http:\/\/47.101.202.111\/?p=2216"},"modified":"2023-04-28T11:28:59","modified_gmt":"2023-04-28T03:28:59","slug":"red-black-tree-hashmap%e7%ba%a2%e9%bb%91%e6%a0%91%e6%ba%90%e7%a0%81%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/139.196.114.170\/?p=2216","title":{"rendered":"Red Black Tree &#8211; \u7ea2\u9ed1\u6811\u900f\u5f7b\u5206\u6790"},"content":{"rendered":"<p>\u672c\u6587\u57fa\u4e8e\u300a\u7b97\u6cd5\u7b2c\u56db\u7248\u300b\u4e2d\u7ea2\u9ed1\u6811\u4f5c\u8005Robert Sedgewick\u7684\u539f\u7406\u8bb2\u89e3\u53ca\u4ee3\u7801\u5b9e\u73b0\uff0c\u4ece2-3\u6811\u89d2\u5ea6\u6765\u89c2\u5bdf\u548c\u7406\u89e3\u7ea2\u9ed1\u6811\u5e73\u8861\u8c03\u6574\u8bbe\u8ba1\u52a8\u673a\uff0c\u6e90\u7801\u5206\u6790\u8bf4\u660e\u57fa\u4e8eJDK 1.8\u7248\u672cHashMap\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904<\/p>\n<p><!--more--><\/p>\n<h2>\u6982\u8ff0<\/h2>\n<p>RBT\uff08Red Black Tree\uff0c\u7ea2\u9ed1\u6811\uff09\u662f\u4e00\u79cdBST\uff08Balanced Search Tree\uff0c\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\uff09\uff0cRBT\u4e0d\u662f\u5b8c\u5168\u5e73\u8861\u4e8c\u53c9\u6811\uff0c\u8fd9\u5bfc\u81f4\u5176\u6811\u9ad8\u6700\u5c0f $\\scriptsize O(\\lg N)$ \u6700\u5927 $\\scriptsize O(2 \\lg N)$ \uff0c\u5373\u7ea2\u9ed1\u6811\u7684\u7684\u63d2\u5165\u548c\u67e5\u8be2\u6027\u80fd<\/p>\n<p>\u7ea2\u9ed1\u6811\u76f8\u6bd4\u4e8e\u5176\u4ed6BST\u7684\u4f18\u70b9\u662f $\\scriptsize O(1)$ \u5e73\u8861\u7ef4\u62a4\u6210\u672c\uff0c\u907f\u514d\u9010\u5c42\u4f20\u9012\u7684\u5e73\u8861\u8c03\u6574\uff0c\u56e0\u800c\u88ab\u5e7f\u6cdb\u4f7f\u7528<\/p>\n<h2>\u5e94\u7528<\/h2>\n<ul>\n<li>linux\u5185\u6838CFS\u8fdb\u7a0b\u8c03\u5ea6\u5668<\/li>\n<li>EXT3\u6587\u4ef6\u7cfb\u7edf<\/li>\n<li>Java\u548cC++\u4e2d\u7684Map\u548cSet<\/li>\n<\/ul>\n<h2>\u6027\u8d28<\/h2>\n<ul>\n<li>\u8282\u70b9\u4ec5\u7ea2\u8272\u6216\u4ec5\u9ed1\u8272<\/li>\n<li>\u6839\u8282\u70b9\u4e3a\u9ed1\u8272<\/li>\n<li>\u53f6\u8282\u70b9\u4e3a\u9ed1\u8272\uff08NULL\u4e5f\u7b97\u53f6\u8282\u70b9\uff09<\/li>\n<li>\u7ea2\u8282\u70b9\u7684\u7236\u3001\u5b50\u8282\u70b9\u4e3a\u9ed1\u8272\uff0c\u9ed1\u8282\u70b9\u7236\u3001\u5b50\u8282\u70b9\u53ef\u7ea2\u53ef\u9ed1<\/li>\n<li>\u4efb\u4e00\u8282\u70b9\u4e3a\u6839\u51fa\u53d1\u5230\u53f6\u8282\u70b9\u7684\u6240\u6709\u8def\u5f84\u4e0a\u9ed1\u8272\u8282\u70b9\u6570<strong>\uff08\u9ed1\u9ad8\uff09<\/strong>\u76f8\u540c<\/li>\n<li>RBT\u4e2d\u5e8f\u904d\u5386\u4e3a\u5347\u5e8f\u5e8f\u5217<\/li>\n<\/ul>\n<h2>\u5b9e\u73b0<\/h2>\n<p>\u4ee5Java\u4e2d\u7684HashMap\u6e90\u7801\u4e3a\u4f8b<\/p>\n<h3>\u5e73\u8861\u65cb\u8f6c\u64cd\u4f5c<\/h3>\n<p>\u65cb\u8f6c\u7684\u76ee\u7684\u662f\u964d\u4f4e\u540e\u6587\u4e2dLL\u548cRR\u578b\u6811\u7684\u9ad8\u5ea6\uff0c\u4f7f\u6811\u66f4\u5e73\u8861\u3002\u5206\u4e3a\u5de6\u65cb\u4e0e\u53f3\u65cb\uff0c\u6b64\u5904\u4ee5\u5de6\u65cb\u4e3a\u4f8b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/\u7ea2\u9ed1\u6811\u5de6\u65cb\u64cd\u4f5c.png\" alt=\"rotate operation\" \/><\/p>\n<pre lang=\"java\">\nstatic <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root, TreeNode<K,V> p) {\n    TreeNode<K,V> r, pp, rl;\n    if (p != null && (r = p.right) != null) {\n        if ((rl = p.right = r.left) != null)       \/\/ 1 \u5de6\u65cb\u540erl\u6210\u4e3ap\u7684\u5b50\u8282\u70b9\n            rl.parent = p;\n        if ((pp = r.parent = p.parent) == null)    \/\/ 2 \u5de6\u65cb\u540er\u66ff\u4ee3\u539fp\u4f4d\u7f6e\uff0c\u6210\u4e3aroot\n            (root = r).red = false;\n        else if (pp.left == p)                     \/\/ 2 \u5de6\u65cb\u540er\u66ff\u4ee3\u539fp\u4f4d\u7f6e\uff0c\u6210\u4e3app.left\n            pp.left = r;\n        else\n            pp.right = r;                          \/\/ 2 \u5de6\u65cb\u540er\u66ff\u4ee3\u539fp\u4f4d\u7f6e\uff0c\u6210\u4e3app.right\n        r.left = p;                                \/\/ 3 \u5de6\u65cb\u4fee\u6539\u6307\u9488\n        p.parent = r;                              \/\/ 4 \u5de6\u65cb\u4fee\u6539\u6307\u9488\n    }\n    return root;\n}\n<\/pre>\n<h3>\u63d2\u5165\u64cd\u4f5c<\/h3>\n<h4>\u63d2\u5165\u8282\u70b9<\/h4>\n<p>\u6839\u636eBST\u6027\u8d28\u627e\u5230\u63d2\u5165\u4f4d\u7f6e<\/p>\n<pre lang=\"java\">\nfinal void treeify(HashMap.Node<K,V>[] tab) {\n    HashMap.TreeNode<K,V> root = null;\n    for (HashMap.TreeNode<K,V> x = this, next; x != null; x = next) {\n        next = (HashMap.TreeNode<K,V>)x.next;\n        x.left = x.right = null;\n        if (root == null) {                                       \/\/ \u6839\u8282\u70b9\u5355\u72ec\u5904\u7406\n            x.parent = null;\n            x.red = false;\n            root = x;\n        }\n        else {\n            K k = x.key;\n            int h = x.hash;\n            Class<?> kc = null;\n            for (HashMap.TreeNode<K,V> p = root;;) {              \/\/ \u8fed\u4ee3\u627e\u5230\u63d2\u5165\u4f4d\u7f6e\n                int dir, ph;\n                K pk = p.key;\n                if ((ph = p.hash) > h)                            \/\/ \u5c0f\u8282\u70b9\u63d2\u5165\u4f4d\u7f6e\u5728\u5de6\u5b50\u6811\n                    dir = -1;\n                else if (ph < h)                                  \/\/ \u5927\u8282\u70b9\u63d2\u5165\u4f4d\u7f6e\u5728\u53f3\u5b50\u6811\n                    dir = 1;\n                else if ((kc == null &#038;&#038;\n                        (kc = comparableClassFor(k)) == null) ||\n                        (dir = compareComparables(kc, k, pk)) == 0)\n                    dir = tieBreakOrder(k, pk);\n\n                HashMap.TreeNode<K,V> xp = p;\n                if ((p = (dir <= 0) ? p.left : p.right) == null) { \/\/ null\u4e3a\u63d2\u5165\u4f4d\u7f6e\uff0c\u5426\u5219\u8fed\u4ee3\u627e\u5b50\u6811\n                    x.parent = xp;\n                    if (dir <= 0)\n                        xp.left = x;                               \/\/ \u6267\u884c\u5c0f\u8282\u70b9\u63d2\u5165\u5de6\u5b50\u6811\n                    else\n                        xp.right = x;                              \/\/ \u6267\u884c\u5927\u8282\u70b9\u63d2\u5165\u53f3\u5b50\u6811\n                    root = balanceInsertion(root, x);              \/\/ \u5e73\u8861\u8c03\u6574\n                    break;\n                }\n            }\n        }\n    }\n    moveRootToFront(tab, root);\n}\n<\/pre>\n<h4>\u5e73\u8861\u8c03\u6574<\/h4>\n<p>\u9700\u8981\u68c0\u67e5\u63d2\u5165\u7684\u65b0\u8282\u70b9\u662f\u5426\u7834\u574f\u4e86RBT\u6027\u8d28\uff0c\u82e5\u7834\u574f\u5219\u9700\u8981\u8fdb\u884c\u5e73\u8861\u8c03\u6574\u4ee5\u4fdd\u8bc1RBT\u6027\u8d28\u4f7f\u6811\u5e73\u8861\u3002\u5bfc\u81f4\u4e0d\u6ee1\u8db3RBT\u6027\u8d28\u7684\u539f\u56e0\u6709\u4e09\uff1a<\/p>\n<ul>\n<li>CASE1\uff1a\u5206\u4e3aL\u578b\u548cR\u578b\uff0c\u6b64\u5904\u5206\u6790L\u578b<br \/>\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/\u7ea2\u9ed1\u6811\u8c03\u65741.png\" alt=\"case1\" \/><\/li>\n<li>CASE2\uff1a\u5206\u4e3aLR\u578b\u548cRL\u578b\uff0c\u6b64\u5904\u5206\u6790LR\u578b<br \/>\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/\u7ea2\u9ed1\u6811\u8c03\u65742.png\" alt=\"case1\" \/><\/li>\n<li>CASE3\uff1a\u5206\u4e3aLL\u578b\u548cRR\u578b\uff0c\u6b64\u5904\u5206\u6790LL\u578b<br \/>\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/\u7ea2\u9ed1\u6811\u8c03\u65743.png\" alt=\"case1\" \/><\/li>\n<\/ul>\n<pre lang=\"java\">\nstatic <K,V> TreeNode<K,V> balanceInsertion(TreeNode<K,V> root, TreeNode<K,V> x) {\n    x.red = true;                                              \/\/ \u65b0\u63d2\u8282\u70b9\u5747\u89c6\u4e3aRED\u8282\u70b9\n    for (TreeNode<K,V> xp, xpp, xppl, xppr;;) {\n        if ((xp = x.parent) == null) {\n            x.red = false;\n            return x;\n        }\n        else if (!xp.red || (xpp = xp.parent) == null)         \/\/ \u7ea2\u8282\u70b9\u624d\u662f\u4e0d\u5e73\u8861\u539f\u56e0\uff0c\u9ed1\u8282\u70b9\u4ee5\u4e0a\u5747\u6ee1\u8db3RBT\u6027\u8d28\n            return root;                                       \/\/ \u7b2c\u4e00\u6b21\u63d2\u5165\u6839\u8282\u70b9\u65f6\u3001\u5411\u4e0a\u68c0\u67e5\u81f3\u6839\u8282\u70b9\u65f6\u5168\u6811\u5df2\u5e73\u8861\n        if (xp == (xppl = xpp.left)) {\n            if ((xppr = xpp.right) != null && xppr.red) {      \/\/ CASE1:L\n                xppr.red = false;\n                xp.red = false;\n                xpp.red = true;\n                x = xpp;\n            }\n            else {\n                if (x == xp.right) {                           \/\/ CASE2:LR\n                    root = rotateLeft(root, x = xp);\n                    xpp = (xp = x.parent) == null ? null : xp.parent;\n                }\n                if (xp != null) {                              \/\/ CASE3:LL\n                    xp.red = false;\n                    if (xpp != null) {\n                        xpp.red = true;\n                        root = rotateRight(root, xpp);\n                    }\n                }\n            }\n        }\n        else {\n            if (xppl != null && xppl.red) {                    \/\/ CASE1:R\n                xppl.red = false;\n                xp.red = false;\n                xpp.red = true;\n                x = xpp;\n            }\n            else {\n                if (x == xp.left) {                            \/\/ CASE2:RL\n                    root = rotateRight(root, x = xp);\n                    xpp = (xp = x.parent) == null ? null : xp.parent;\n                }\n                if (xp != null) {                              \/\/ CASE3:RR\n                    xp.red = false;\n                    if (xpp != null) {\n                        xpp.red = true;\n                        root = rotateLeft(root, xpp);\n                    }\n                }\n            }\n        }\n    }\n}\n<\/pre>\n<h3>\u5220\u9664\u64cd\u4f5c<\/h3>\n<h4>\u5220\u9664\u8282\u70b9<\/h4>\n<p>\u9996\u5148\u67e5\u627e\u5230\u5f85\u5220\u8282\u70b9\uff0c\u518d\u786e\u5b9a\u5408\u9002\u7684\u5b50\u8282\u70b9\u66ff\u6362\u5f85\u5220\u8282\u70b9\uff0c\u5176\u5b9e\u5c31\u662fBST\u7684\u8282\u70b9\u5220\u9664\uff0c\u8be6\u89c1\u4e0b\u56fe<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/bst-delete-node.png\" alt=\"bst-delete\" \/><\/p>\n<p>\u5f85\u5220\u8282\u70b9\u53ea\u6709\u5de6\u5b69\u5b50\u6216\u53ea\u6709\u53f3\u5b69\u5b50\u7684\u60c5\u51b5\u53ef\u53d6\u5b50\u8282\u70b9\u76f4\u63a5\u66ff\u4ee3<\/p>\n<p>\u4f46\u82e5\u540c\u65f6\u6709\u5de6\u53f3\u5b69\u5b50\uff0c\u4ecd\u53d6\u76f4\u63a5\u5b50\u8282\u70b9\u66ff\u6362\u7684\u8bdd\u4f1a\u5e26\u6765\u95ee\u9898\uff1a\u5982\u53d6l\u66ff\u6362u\u9700\u8981\u5c06LR\u5206\u652f\u63d2\u5165r\u5b50\u6811\u7684L\u5206\u652f\uff0c\u53ef\u80fd\u4f1a\u589e\u52a0\u6811\u7684\u9ad8\u5ea6\u964d\u4f4e\u67e5\u8be2\u6027\u80fd\u3002r\u66ff\u6362u\u540c\u7406\u3002\u4e0d\u63a8\u8350<\/p>\n<p>\u4e3a\u4e86\u7ef4\u62a4BST\u6027\u8d28\uff0c\u53d6l&lt;v&lt;r\u7684\u8282\u70b9v\u66ff\u6362\u8282\u70b9u\u8f83\u4e3a\u5408\u9002\u3002\u800c\u53d6r\u5b50\u6811\u7684\u6700\u5c0f\u8282\u70b9v\u65f6\uff0cv\u53ea\u53ef\u80fd\u6709\u53f3\u5b69\u5b50\uff0c\u6b64\u65f6\u4fee\u6539\u6700\u5c11\uff1b\u9009\u62e9lmax\u540c\u7406<\/p>\n<p>r\u53f3\u5b50\u6811\u7684\u6700\u5c0f\u8282\u70b9\u5c31\u662fr\u672c\u8eab\u3001\u6216\u65e0\u53f3\u5b69\u5b50\u65f6\u53ef\u76f4\u63a5\u66ff\u6362\u5f85\u5220\u8282\u70b9\u3002\u82e5\u4e0d\u662f\u5219\u8bf4\u660er\u53f3\u5b50\u6811\u7684\u6700\u5c0f\u8282\u70b9v\u8fd8\u6709\u53f3\u5b50\u6811vr\uff0c\u9700\u8981\u4f9d\u6b21\u6267\u884cv\u66ff\u6362u\u3001vr\u66ff\u6362v<\/p>\n<h5>\u5b89\u5168\u5730\u5220\u9664\u7ea2\u8272\u8282\u70b9<\/h5>\n<hr \/>\n<p>\u4ece2-3\u6811\u7684\u89c6\u89d2\u6765\u770b\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u5168\u6811\u4ecd\u7136\u4fdd\u6301\u5e73\u8861\uff1a<br \/>\n\u6240\u6709\u7ea2\u8272\u8282\u70b9\u5747\u57283-\u8282\u70b9\u4e2d\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u4ec5\u662f\u5c063-\u8282\u70b9\u53d8\u4e3a2-\u8282\u70b9\uff0c2-3\u6811\u4efb\u4f55\u5b50\u6811\u7684\u9ad8\u5ea6\u5747\u672a\u53d1\u751f\u53d8\u5316<\/p>\n<hr \/>\n<p>\u4ece\u7ea2\u9ed1\u6811\u7684\u89c6\u89d2\u6765\u770b\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u4e0d\u6539\u53d8\u7ea2\u9ed1\u6811\u7684\u6027\u8d28\uff1a<br \/>\n\u5220\u9664\u7ea2\u8272\u8282\u70b9\u5e76\u4e0d\u4f1a\u6539\u53d8\u6240\u5728\u8def\u5f84\u4e0a\u7684\u9ed1\u8272\u8282\u70b9\u6570\u76ee\uff0c\u5373\u9ed1\u9ad8\u4e0d\u53d8<br \/>\n\u5f85\u5220\u7ea2\u8272\u8282\u70b9\u88ab\u9ed1\u8272\u8282\u70b9\u66ff\u4ee3\u65f6\uff0c\u5fc5\u7136\u4e0d\u4f1a\u5f15\u8d77\u53cc\u7ea2\u95ee\u9898<br \/>\n\u5f85\u5220\u7ea2\u8272\u8282\u70b9\u88ab\u7ea2\u8272\u8282\u70b9\u66ff\u4ee3\u65f6\uff0c\u5176\u76f4\u63a5\u7236\u5b50\u8282\u70b9\u5fc5\u4e3a\u9ed1\u8272\uff0c\u76f4\u63a5\u5b50\u8282\u70b9\u66ff\u6362\u65f6\u5fc5\u7136\u4e0d\u4f1a\u4ea7\u751f\u53cc\u7ea2\uff0c\u5373\u4f7f\u66ff\u6362\u8282\u70b9v\u662f\u7ea2\u8272\u4e5f\u4e0d\u4f1a\u9020\u6210\u539f\u5f85\u5220\u4f4d\u7f6eu\u53d1\u751f\u53cc\u7ea2\uff08\u4e0b\u56fe\u4f8b3\uff09\uff0c\u800c\u7ea2\u8272\u7684\u66ff\u6362\u8282\u70b9v\u9650\u5236rl\u548cvr\u5fc5\u4e3a\u9ed1\u8272\uff0c\u5176\u53f3\u5b69\u5b50vr\u66ff\u6362v\u65f6\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u53cc\u7ea2\uff08\u4e0b\u56fe\u4f8b4\uff09<br \/>\n\u7531\u4e8e\u7ea2\u8272\u8282\u70b9\u4e0d\u662f\u6839\u8282\u70b9\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u540e\u7684\u66ff\u4ee3\u4e0d\u662f\u6839\u8282\u70b9\uff0c\u4e5f\u6ca1\u6709\u5411\u6839\u8282\u70b9\u7684\u989c\u8272\u8c03\u6574\uff0c\u6839\u4ecd\u7136\u4fdd\u6301\u9ed1\u8272<\/p>\n<hr \/>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/double-black-check1.png?w=525\" alt=\"delete-check-1\" data-recalc-dims=\"1\" \/><\/p>\n<h5>\u8c28\u614e\u5730\u5220\u9664\u9ed1\u8272\u8282\u70b9<\/h5>\n<hr \/>\n<p>\u4ece2-3\u6811\u7684\u89c6\u89d2\u6765\u770b\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u5168\u6811\u4ecd\u7136\u4fdd\u6301\u5e73\u8861\uff1a<br \/>\n\u6240\u6709\u7ea2\u8272\u8282\u70b9\u5747\u57283-\u8282\u70b9\u4e2d\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u4ec5\u662f\u5c063-\u8282\u70b9\u53d8\u4e3a2-\u8282\u70b9\uff0c2-3\u6811\u4efb\u4f55\u5b50\u6811\u7684\u9ad8\u5ea6\u5747\u672a\u53d1\u751f\u53d8\u5316<\/p>\n<hr \/>\n<p>\u4ece\u7ea2\u9ed1\u6811\u7684\u89c6\u89d2\u6765\u770b\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u4e0d\u6539\u53d8\u7ea2\u9ed1\u6811\u7684\u6027\u8d28\uff1a<br \/>\n\u5220\u9664\u7ea2\u8272\u8282\u70b9\u5e76\u4e0d\u4f1a\u6539\u53d8\u6240\u5728\u8def\u5f84\u4e0a\u7684\u9ed1\u8272\u8282\u70b9\u6570\u76ee\uff0c\u5373\u9ed1\u9ad8\u4e0d\u53d8<br \/>\n\u5f85\u5220\u7ea2\u8272\u8282\u70b9\u88ab\u9ed1\u8272\u8282\u70b9\u66ff\u4ee3\u65f6\uff0c\u5fc5\u7136\u4e0d\u4f1a\u5f15\u8d77\u53cc\u7ea2\u95ee\u9898<br \/>\n\u5f85\u5220\u7ea2\u8272\u8282\u70b9\u88ab\u7ea2\u8272\u8282\u70b9\u66ff\u4ee3\u65f6\uff0c\u5176\u76f4\u63a5\u7236\u5b50\u8282\u70b9\u5fc5\u4e3a\u9ed1\u8272\uff0c\u76f4\u63a5\u5b50\u8282\u70b9\u66ff\u6362\u65f6\u5fc5\u7136\u4e0d\u4f1a\u4ea7\u751f\u53cc\u7ea2\uff0c\u5373\u4f7f\u66ff\u6362\u8282\u70b9v\u662f\u7ea2\u8272\u4e5f\u4e0d\u4f1a\u9020\u6210\u539f\u5f85\u5220\u4f4d\u7f6eu\u53d1\u751f\u53cc\u7ea2\uff08\u4e0b\u56fe\u4f8b3\uff09\uff0c\u800c\u7ea2\u8272\u7684\u66ff\u6362\u8282\u70b9v\u9650\u5236rl\u548cvr\u5fc5\u4e3a\u9ed1\u8272\uff0c\u5176\u53f3\u5b69\u5b50vr\u66ff\u6362v\u65f6\u4e5f\u4e0d\u4f1a\u51fa\u73b0\u53cc\u7ea2\uff08\u4e0b\u56fe\u4f8b4\uff09<br \/>\n\u7531\u4e8e\u7ea2\u8272\u8282\u70b9\u4e0d\u662f\u6839\u8282\u70b9\uff0c\u5220\u9664\u7ea2\u8272\u8282\u70b9\u540e\u7684\u66ff\u4ee3\u4e0d\u662f\u6839\u8282\u70b9\uff0c\u4e5f\u6ca1\u6709\u5411\u6839\u8282\u70b9\u7684\u989c\u8272\u8c03\u6574\uff0c\u6839\u4ecd\u7136\u4fdd\u6301\u9ed1\u8272<\/p>\n<hr \/>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/tihar-tech.cn\/wp-content\/uploads\/2022\/08\/double-black-check2.png?w=525\" alt=\"delete-check-2\" data-recalc-dims=\"1\" \/><\/p>\n<h4>\u5e73\u8861\u8c03\u6574<\/h4>\n<h5>case1<\/h5>\n<h5>case2<\/h5>\n<h5>case3<\/h5>\n<h5>case4<\/h5>\n<h4>\u53c2\u8003\u8d44\u6599<\/h4>\n<p>Thomas H. Cormen,Charles E. Leiserson,Ronald L. Rivest,Clifford Stein\uff0eIntroduction to Algorithms, Third Edition\uff0e[M]. \u5317\u4eac:\u673a\u68b0\u5de5\u4e1a\u51fa\u7248\u793e, 2013. 1<br \/>\nSedgewick R, Wayne K. Algorithms, Fourth Edition[M]. 4. \u4eba\u6c11\u90ae\u7535\u51fa\u7248\u793e, 2012.<br \/>\n<a href=\"https:\/\/algs4.cs.princeton.edu\/33balanced\/RedBlackBST.java.html\">RedBlackBST - Robert Sedgewick - Princeton University<\/a><br \/>\n\u9093\u4fca\u8f89. \u6570\u636e\u7ed3\u6784\uff08C++\u8bed\u8a00\u7248 \u7b2c3\u7248\uff09[M]. 3. \u6e05\u534e\u5927\u5b66\u51fa\u7248\u793e, 2013.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u57fa\u4e8e\u300a\u7b97\u6cd5\u7b2c\u56db\u7248\u300b\u4e2d\u7ea2\u9ed1\u6811\u4f5c\u8005Robert Sedgewick\u7684\u539f\u7406\u8bb2\u89e3\u53ca\u4ee3\u7801\u5b9e\u73b0\uff0c\u4ece2-3\u6811\u89d2\u5ea6\u6765\u89c2\u5bdf\u548c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/139.196.114.170\/?p=2216\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cRed Black Tree &#8211; \u7ea2\u9ed1\u6811\u900f\u5f7b\u5206\u6790\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/2216"}],"collection":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2216"}],"version-history":[{"count":21,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/2216\/revisions"}],"predecessor-version":[{"id":2803,"href":"http:\/\/139.196.114.170\/index.php?rest_route=\/wp\/v2\/posts\/2216\/revisions\/2803"}],"wp:attachment":[{"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2216"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.196.114.170\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}