{"id":120976,"date":"2026-11-01T21:57:06","date_gmt":"2026-11-01T13:57:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/120976.html"},"modified":"2026-11-01T21:57:06","modified_gmt":"2026-11-01T13:57:06","slug":"%e3%80%90c%e3%80%91avl-%e6%a0%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/120976.html","title":{"rendered":"\u3010C++\u3011AVL \u6811"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"1.%20AVL%E7%9A%84%E6%A6%82%E5%BF%B5%E2%80%8B%E7%BC%96%E8%BE%91-toc\" style=\"margin-left:0px\">1. AVL\u7684\u6982\u5ff5\u200b\u7f16\u8f91<\/p>\n<p id=\"2.%20AVL%20%E6%A0%91%E7%9A%84%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:0px\">2. AVL \u6811\u7684\u5b9e\u73b0<\/p>\n<p id=\"2.1%20AVL%20%E6%A0%91%E7%9A%84%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">2.1 AVL \u6811\u7684\u7ed3\u6784<\/p>\n<p id=\"2.2%20AVL%20%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5-toc\" style=\"margin-left:40px\">2.2 AVL \u6811\u7684\u63d2\u5165<\/p>\n<p id=\"2.3%20%E6%97%8B%E8%BD%AC-toc\" style=\"margin-left:40px\">2.3 \u65cb\u8f6c<\/p>\n<p id=\"2.4%20AVL%20%E6%A0%91%E7%9A%84%E6%9F%A5%E6%89%BE-toc\" style=\"margin-left:40px\">2.4 AVL \u6811\u7684\u67e5\u627e<\/p>\n<p id=\"2.5%20AVL%20%E6%A0%91%E7%9A%84%E5%B9%B3%E8%A1%A1%E6%A3%80%E6%9F%A5-toc\" style=\"margin-left:40px\">2.5 AVL \u6811\u7684\u5e73\u8861\u68c0\u67e5<\/p>\n<p id=\"2.6%20AVL%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4-toc\" style=\"margin-left:40px\">2.6 AVL\u6811\u7684\u5220\u9664<\/p>\n<hr id=\"hr-toc\" \/>\n<h2><span style=\"color:#1f2329\">1. AVL\u7684\u6982\u5ff5<\/span><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"442\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135703-6ae7452f6be06.png\" width=\"756\" \/><\/h2>\n<p>AVL \u6811\u7531\u524d\u82cf\u8054\u6570\u5b66\u5bb6 G.M. Adelson-Velsky&#xff08;\u963f\u5fb7\u5c14\u68ee &#8211; \u97e6\u5c14\u65af\u57fa&#xff09; \u548c E.M. Landis&#xff08;\u5170\u8fea\u65af&#xff09; \u5728 1962 \u5e74\u63d0\u51fa\u5e76\u53d1\u8868\u8bba\u6587&#xff0c;\u5b83\u4e5f\u662f\u4e16\u754c\u4e0a\u7b2c\u4e00\u4e2a\u81ea\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u3002<\/p>\n<p id=\"AVL%20%E5%92%8C%E6%99%AE%E9%80%9A%E4%BA%8C%E5%8F%89%E6%90%9C%E7%B4%A2%E6%A0%91%EF%BC%88BST%EF%BC%89%E6%9C%80%E5%A4%A7%E5%8C%BA%E5%88%AB\">AVL \u548c\u666e\u901a\u4e8c\u53c9\u641c\u7d22\u6811&#xff08;BST&#xff09;\u6700\u5927\u533a\u522b<\/p>\n<p>AVL \u672c\u8d28\u4e0a\u4f9d\u7136\u662f\u4e00\u68f5\u4e8c\u53c9\u641c\u7d22\u6811&#xff0c;\u4fdd\u7559 BST \u7684\u6709\u5e8f\u6027\u8d28&#xff1b;\u989d\u5916\u589e\u52a0\u4e00\u6761\u5e73\u8861\u7ea6\u675f&#xff1a;\u6811\u4e2d\u4efb\u610f\u8282\u70b9&#xff0c;\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc7 1&#xff08;\u5e73\u8861\u56e0\u5b50 \u2208 {-1,0,1}&#xff09;\u3002\u4e00\u65e6\u63d2\u5165\u3001\u5220\u9664\u9020\u6210\u5931\u8861&#xff0c;\u4f1a\u901a\u8fc7\u65cb\u8f6c\u81ea\u52a8\u8c03\u6574\u7ed3\u6784\u3001\u6062\u590d\u5e73\u8861&#xff1b;\u666e\u901a BST \u6ca1\u6709\u8fd9\u4e2a\u81ea\u52a8\u5e73\u8861\u673a\u5236&#xff0c;\u6811\u5f62\u6001\u5b8c\u5168\u7531\u63d2\u5165\u987a\u5e8f\u51b3\u5b9a\u3002<\/p>\n<p id=\"AVL%20%E6%A0%91%E8%BF%9B%E6%AD%A5%E7%9A%84%E5%9C%B0%E6%96%B9\">AVL \u6811\u8fdb\u6b65\u7684\u5730\u65b9<\/p>\n<li>\u64cd\u4f5c\u590d\u6742\u5ea6\u7a33\u5b9a&#xff1a;\u67e5\u627e\u3001\u63d2\u5165\u3001\u5220\u9664\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u7a33\u5b9a \\\\(O(\\\\log n)\\\\)&#xff0c;\u4e0d\u4f1a\u9000\u5316\u6210\u94fe\u8868&#xff0c;\u6d88\u9664\u4e86 BST \u6700\u574f \\\\(O(n)\\\\) \u7684\u98ce\u9669\u3002<\/li>\n<li>\u6811\u9ad8\u88ab\u4e25\u683c\u9650\u5236&#xff0c;\u6811\u66f4 \u201c\u77ee\u201d&#xff0c;\u67e5\u627e\u901f\u5ea6\u5f88\u5feb&#xff0c;\u9002\u5408\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\u3002<\/li>\n<li>\u81ea\u5e73\u8861\u673a\u5236&#xff1a;\u589e\u5220\u540e\u81ea\u52a8\u65cb\u8f6c\u4fee\u590d\u5e73\u8861&#xff0c;\u4e0d\u9700\u8981\u4eba\u5de5\u91cd\u6784\u6574\u68f5\u6811\u3002<\/li>\n<p id=\"AVL%20%E6%A0%91%E7%9A%84%E7%BC%BA%E7%82%B9\">AVL \u6811\u7684\u7f3a\u70b9<\/p>\n<li>\u5e73\u8861\u6761\u4ef6\u5f88\u4e25\u683c&#xff0c;\u63d2\u5165\u3001\u5220\u9664\u5f88\u5bb9\u6613\u89e6\u53d1\u65cb\u8f6c&#xff0c;\u5c24\u5176\u662f\u5220\u9664\u64cd\u4f5c&#xff0c;\u53ef\u80fd\u9700\u8981\u6cbf\u7740\u8def\u5f84\u5411\u4e0a\u591a\u6b21\u65cb\u8f6c&#xff0c;\u8c03\u6574\u5f00\u9500\u5927\u3001\u5199\u64cd\u4f5c\u4ee3\u4ef7\u9ad8\u3002<\/li>\n<li>\u6bcf\u4e2a\u8282\u70b9\u9700\u8981\u989d\u5916\u8bb0\u5f55\u5b50\u6811\u9ad8\u5ea6&#xff08;\u6216\u8005\u5e73\u8861\u56e0\u5b50&#xff09;&#xff0c;\u5360\u7528\u989d\u5916\u5b58\u50a8\u7a7a\u95f4\u3002<\/li>\n<li>\u65cb\u8f6c\u903b\u8f91\u591a&#xff08;LL\u3001RR\u3001LR\u3001RL \u56db\u79cd\u60c5\u51b5&#xff09;&#xff0c;\u4ee3\u7801\u5b9e\u73b0\u3001\u8c03\u8bd5\u66f4\u590d\u6742\u3002<\/li>\n<li>\u5199\u5bc6\u96c6\u573a\u666f\u4e0d\u5982\u7ea2\u9ed1\u6811\u5408\u9002&#xff0c;\u6240\u4ee5\u5de5\u7a0b\u91cc C&#043;&#043; map \u7b49\u5bb9\u5668\u5e95\u5c42\u9009\u7528\u7ea2\u9ed1\u6811\u800c\u4e0d\u662f AVL\u3002<\/li>\n<h2 id=\"2.%20AVL%20%E6%A0%91%E7%9A%84%E5%AE%9E%E7%8E%B0\">2. AVL \u6811\u7684\u5b9e\u73b0<\/h2>\n<h3 id=\"2.1%20AVL%20%E6%A0%91%E7%9A%84%E7%BB%93%E6%9E%84\">2.1 AVL \u6811\u7684\u7ed3\u6784<\/h3>\n<p>using namespace std;<br \/>\ntemplate&lt;class T&gt;<br \/>\nstruct AVLTreeNode<br \/>\n{<br \/>\nAVLTreeNode(const T&amp; data &#061; T())<br \/>\n: _pLeft(nullptr)<br \/>\n, _pRight(nullptr)<br \/>\n, _pParent(nullptr)<br \/>\n, _data(data)<br \/>\n, _bf(0)<br \/>\n{<br \/>\n}<\/p>\n<p>AVLTreeNode&lt;T&gt;* _pLeft;<br \/>\nAVLTreeNode&lt;T&gt;* _pRight;<br \/>\nAVLTreeNode&lt;T&gt;* _pParent;<br \/>\nT _data;<br \/>\nint _bf;   \/\/ \u8282\u70b9\u7684\u5e73\u8861\u56e0\u5b50<br \/>\n};<\/p>\n<p>\/\/ \u5de6\u52a0 \u53f3\u51cf<br \/>\n\/\/ AVL: \u4e8c\u53c9\u641c\u7d22\u6811 &#043; \u5e73\u8861\u56e0\u5b50\u7684\u9650\u5236<br \/>\ntemplate&lt;class T&gt;<br \/>\nclass AVLTree<br \/>\n{<br \/>\ntypedef AVLTreeNode&lt;T&gt; Node;<br \/>\npublic:<br \/>\n\/\/ \u521d\u59cb\u9ed8\u8ba4\u6784\u9020<br \/>\nAVLTree()<br \/>\n: _pRoot(nullptr)<br \/>\n{<\/p>\n<p>}<\/p>\n<p>private:<br \/>\nNode* _pRoot;<br \/>\n}; <\/p>\n<h3 id=\"2.2%20AVL%20%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5\">2.2 AVL \u6811\u7684\u63d2\u5165<\/h3>\n<p>2.2.1 AVL \u63d2\u5165\u7684\u5927\u6982\u8fc7\u7a0b<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5411 AVL \u6811\u63d2\u5165\u8282\u70b9\u65f6&#xff0c;\u9996\u5148\u6309\u7167\u666e\u901a\u4e8c\u53c9\u641c\u7d22\u6811\u89c4\u5219\u627e\u5230\u7a7a\u4f4d\u63d2\u5165\u65b0\u8282\u70b9\u3002\u63d2\u5165\u5b8c\u6210\u540e&#xff0c;\u4ece\u65b0\u8282\u70b9\u5411\u4e0a\u56de\u6eaf&#xff0c;\u4f9d\u6b21\u66f4\u65b0\u6cbf\u9014\u6bcf\u4e2a\u7956\u5148\u8282\u70b9\u7684\u9ad8\u5ea6&#xff0c;\u8ba1\u7b97\u5e73\u8861\u56e0\u5b50\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u82e5\u6240\u6709\u8282\u70b9\u5e73\u8861\u56e0\u5b50\u7edd\u5bf9\u503c\u90fd\u4e0d\u5927\u4e8e 1&#xff0c;\u6811\u4fdd\u6301\u5e73\u8861&#xff0c;\u63d2\u5165\u7ed3\u675f\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5982\u679c\u67d0\u4e2a\u8282\u70b9\u5e73\u8861\u56e0\u5b50\u8d85\u51fa\u8303\u56f4&#xff0c;\u8bf4\u660e\u53d1\u751f\u5931\u8861&#xff0c;\u9700\u8981\u5224\u65ad\u5931\u8861\u7c7b\u578b&#xff1a;LL\u3001RR\u3001LR\u3001RL&#xff0c;\u5bf9\u5e94\u6267\u884c\u5355\u65cb\u8f6c\u6216\u8005\u53cc\u65cb\u8f6c\u8c03\u6574\u7ed3\u6784&#xff0c;\u8ba9\u8be5\u5b50\u6811\u6062\u590d\u5e73\u8861\u3002\u65cb\u8f6c\u5b8c\u6210\u540e&#xff0c;\u7ee7\u7eed\u5411\u4e0a\u68c0\u67e5\u4e0a\u5c42\u8282\u70b9\u662f\u5426\u5931\u8861&#xff0c;\u76f4\u5230\u6839\u8282\u70b9\u3002AVL \u4f9d\u9760\u65cb\u8f6c\u4fdd\u8bc1\u4efb\u610f\u8282\u70b9\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u4e0d\u8d85\u8fc7 1&#xff0c;\u7ef4\u6301\u6811\u9ad8\u4e3a\u5bf9\u6570\u7ea7\u522b&#xff0c;\u4fdd\u8bc1\u67e5\u627e\u6548\u7387\u7a33\u5b9a\u3002<\/p>\n<p>2.2.2 \u5e73\u8861\u56e0\u5b50\u7684\u66f4\u65b0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5e73\u8861\u56e0\u5b50 &#061; \u5de6\u5b50\u6811\u9ad8\u5ea6 \u2212 \u53f3\u5b50\u6811\u9ad8\u5ea6\u3002 \u63d2\u5165\u65b0\u8282\u70b9\u540e&#xff0c;\u4ece\u65b0\u8282\u70b9\u7684\u7236\u8282\u70b9\u5f00\u59cb\u5f80\u6839\u65b9\u5411\u56de\u6eaf&#xff1a;\u5148\u66f4\u65b0\u5f53\u524d\u8282\u70b9\u7684\u9ad8\u5ea6&#xff0c;\u518d\u91cd\u65b0\u8ba1\u7b97\u5b83\u7684\u5e73\u8861\u56e0\u5b50\u3002<\/p>\n<ul>\n<li>\u5e73\u8861\u56e0\u5b50\u7edd\u5bf9\u503c\u22641&#xff1a;\u8be5\u8282\u70b9\u5e73\u8861&#xff0c;\u7ee7\u7eed\u5411\u4e0a\u68c0\u67e5\u7956\u5148&#xff1b;<\/li>\n<li>\u5e73\u8861\u56e0\u5b50\u7edd\u5bf9\u503c&#xff1e;1&#xff1a;\u8282\u70b9\u5931\u8861&#xff0c;\u8fdb\u884c\u65cb\u8f6c\u8c03\u6574&#xff1b;\u65cb\u8f6c\u5b8c\u6210\u540e&#xff0c;\u66f4\u65b0\u65cb\u8f6c\u6d89\u53ca\u8282\u70b9\u7684\u9ad8\u5ea6\u4e0e\u5e73\u8861\u56e0\u5b50&#xff0c;\u518d\u7ee7\u7eed\u5411\u4e0a\u5224\u65ad\u4e0a\u5c42\u8282\u70b9\u3002 \u5220\u9664\u8282\u70b9\u65f6\u53d8\u5316\u66f4\u5927&#xff0c;\u5220\u9664\u53ef\u80fd\u8ba9\u7956\u5148\u9ad8\u5ea6\u6301\u7eed\u53d8\u5316&#xff0c;\u9700\u8981\u4e00\u8def\u5411\u4e0a\u66f4\u65b0\u9ad8\u5ea6\u3001\u91cd\u7b97\u5e73\u8861\u56e0\u5b50&#xff0c;\u591a\u6b21\u89e6\u53d1\u8c03\u6574\u3002<\/li>\n<\/ul>\n<p>size_t _Height(Node* pRoot)<br \/>\n{<br \/>\nif (pRoot &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn 0;<br \/>\n}<br \/>\n\/\/ max \u627e\u51fa\u4e24\u6570\u6700\u5927\u6570\u503c<br \/>\nsize_t left &#061; _Height(pRoot-&gt;_pLeft);<br \/>\nsize_t right &#061; _Height(pRoot-&gt;_pRight);<br \/>\nreturn max(left,right) &#043; 1;<br \/>\n}<br \/>\n\/\/ Bf \u8c03\u6574<br \/>\nvoid Bf(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn;<br \/>\nint left &#061; root-&gt;_pLeft ? _Height(root-&gt;_pLeft) : 0;<br \/>\nint right &#061; root-&gt;_pRight ? _Height(root-&gt;_pRight) : 0;<br \/>\nroot-&gt;_bf &#061; left &#8211; right;<br \/>\n} <\/p>\n<p>2.2.2 \u63d2\u5165\u8282\u70b9\u7684\u66f4\u65b0\u5e73\u8861\u97f3\u7cfb\u7684\u4ee3\u7801\u5b9e\u73b0<\/p>\n<p>\/\/ \u5728AVL\u6811\u4e2d\u63d2\u5165\u503c\u4e3adata\u7684\u8282\u70b9<br \/>\nbool Insert(const T&amp; data)<br \/>\n{<br \/>\nif (_pRoot &#061;&#061; nullptr)<br \/>\n{<br \/>\n_pRoot &#061; new Node(data);<br \/>\nreturn true;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nNode* dest &#061; _pRoot, *cur &#061; nullptr;<br \/>\nwhile (dest)<br \/>\n{<br \/>\nif (data &lt; dest-&gt;_data)<br \/>\n{<br \/>\ncur &#061; dest;<br \/>\ndest &#061; dest-&gt;_pLeft;<br \/>\n}<br \/>\nelse if (dest-&gt;_data &lt; data)<br \/>\n{<br \/>\ncur &#061; dest;<br \/>\ndest &#061; dest-&gt;_pRight;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<br \/>\n}<br \/>\ndest &#061; new Node(data);<br \/>\nif (data &lt; cur-&gt;_data)<br \/>\n{<br \/>\ncur-&gt;_pLeft &#061; dest;<br \/>\n}<br \/>\nelse if (cur-&gt;_data &lt; data)<br \/>\n{<br \/>\ncur-&gt;_pRight &#061; dest;<br \/>\n}<br \/>\ndest-&gt;_pParent &#061; cur;<br \/>\n\/\/ \u5411\u4e0a\u8c03\u6574\u5e73\u8861\u6570<br \/>\nBf(cur);<br \/>\nwhile (cur !&#061; nullptr &amp;&amp; abs(cur-&gt;_bf) &lt; 2)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_pParent;<br \/>\nBf(cur);<br \/>\n}<br \/>\n\/\/ \u5982\u679c\u6ca1\u6709\u95ee\u9898\u76f4\u63a5\u9000\u51fa\u6709\u5e73\u8861\u5931\u8861\u7684\u60c5\u51b5\u5c31\u8fdb\u884c\u65cb\u8f6c<br \/>\n            if (cur &#061;&#061; nullptr)<br \/>\nreturn true;<br \/>\nelse if (cur-&gt;_bf &#061;&#061; 2)<br \/>\n{<br \/>\nif (cur-&gt;_pLeft-&gt;_bf &#061;&#061; 1)<br \/>\n{<br \/>\nRotateR(cur);<br \/>\n}<br \/>\nelse if(cur-&gt;_pLeft-&gt;_bf &#061;&#061; -1)<br \/>\n{<br \/>\nRotateLR(cur);<br \/>\n}<br \/>\n}<br \/>\nelse if (cur-&gt;_bf &#061;&#061; -2)<br \/>\n{<br \/>\nif (cur-&gt;_pRight-&gt;_bf &#061;&#061; 1)<br \/>\n{<br \/>\nRotateRL(cur);<br \/>\n}<br \/>\nelse if (cur-&gt;_pRight-&gt;_bf &#061;&#061; -1)<br \/>\n{<br \/>\nRotateL(cur);<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nassert(false);<br \/>\n}<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>} <\/p>\n<h3 id=\"2.3%20%E6%97%8B%E8%BD%AC\">2.3 \u65cb\u8f6c<\/h3>\n<p>2.3.1 \u65cb\u8f6c\u7684\u539f\u5219<\/p>\n<p>\u65cb\u8f6c\u6838\u5fc3\u539f\u5219&#xff1a;\u4e0d\u7834\u574f\u4e8c\u53c9\u641c\u7d22\u6811\u6709\u5e8f\u6027&#xff0c;\u540c\u65f6\u4fee\u6b63\u5931\u8861&#xff0c;\u8c03\u6574\u5b50\u6811\u9ad8\u5ea6\u3001\u66f4\u65b0\u5e73\u8861\u56e0\u5b50\u3002<\/p>\n<li>\u4fdd\u6301 BST \u6027\u8d28&#xff1a;\u65cb\u8f6c\u540e\u4f9d\u65e7\u6ee1\u8db3\u5de6\u5b50\u6811\u503c &lt; \u6839 &lt; \u53f3\u5b50\u6811\u503c&#xff0c;\u4e2d\u5e8f\u904d\u5386\u7ed3\u679c\u4e0d\u53d8\u3002<\/li>\n<li>\u8f6c\u79fb\u5b50\u6811&#xff1a;\u65cb\u8f6c\u65f6\u628a\u4e2d\u95f4\u90a3\u68f5\u5b50\u6811&#xff08;\u88ab\u6324\u51fa\u6765\u7684\u5b50\u6811&#xff09;\u63a5\u5230\u5408\u9002\u4f4d\u7f6e&#xff0c;\u907f\u514d\u4e22\u5931\u8282\u70b9\u3002<\/li>\n<li>\u4f18\u5148\u5904\u7406\u6700\u6df1\u5931\u8861\u8282\u70b9&#xff1a;\u4ece\u4e0b\u5f80\u4e0a\u627e\u5230\u7b2c\u4e00\u4e2a\u5931\u8861\u8282\u70b9&#xff0c;\u4ee5\u5b83\u4e3a\u65cb\u8f6c\u4e2d\u5fc3\u8c03\u6574\u3002<\/li>\n<li>\u65cb\u8f6c\u5b8c\u6210\u540e&#xff0c;\u53ca\u65f6\u66f4\u65b0\u88ab\u6539\u52a8\u8282\u70b9\u7684\u9ad8\u5ea6\u548c\u5e73\u8861\u56e0\u5b50&#xff0c;\u518d\u7ee7\u7eed\u5411\u4e0a\u6821\u9a8c\u3002<\/li>\n<li>\u65cb\u8f6c\u53ea\u6539\u53d8\u6307\u9488\u5173\u7cfb&#xff0c;\u4e0d\u6539\u53d8\u8282\u70b9\u76f8\u5bf9\u5927\u5c0f&#xff1b;\u5355\u65cb\u5904\u7406 LL\u3001RR&#xff0c;\u53cc\u65cb\u5904\u7406 LR\u3001RL\u3002<\/li>\n<p>2.3.2 \u53f3\u5355\u65cb<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"761\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135703-6ae7452f7f2dd.png\" width=\"1982\" \/><\/p>\n<p>\/\/ \u8003\u8651\u95ee\u9898:<br \/>\n\/\/ 1,\u662f\u5426\u6709 Chlid \u7684 \u5de6\u53f3\u8282\u70b9\u662f\u5426\u4e3a\u7a7a(\u4f46\u5176\u5b9e\u53f3\u65cb\u65f6\u5c31R \u53ef\u80fd\u5c31\u662f\u4e3a\u7a7a\u51fa\u73b0\u7684\u53ef\u80fd\u6bd4\u8f83\u5c0f,\u51fa\u73b0\u7684\u8bdd\u5c31\u5df2\u7ecf\u88ab\u5224\u65ad\u9700\u8981\u53cc\u65cb\u4e86)<br \/>\n\/\/ 2,\u8003\u8651\u662f\u5426\u6709 GrandParent \u6709\u9700\u8981\u8fdb\u884c\u4e24\u7ebf\u5bf9\u63a5&#xff0c;\u6ca1\u6709\u5c31\u9700\u8981\u8fdb\u884c\u63d0\u4e0a\u6765\u7684 Child \u7684 Parent \u4e3a\u7a7a<br \/>\n\/\/ \u53f3\u5355\u65cb<br \/>\nvoid RotateR(Node* pParent)<br \/>\n{   \/\/    G       G<br \/>\n\/\/   P      C<br \/>\n\/\/  C  -&gt; L   P<br \/>\n\/\/ L R       R<br \/>\n\/\/<br \/>\n\/\/ pParent -&gt; P<br \/>\n\/\/<br \/>\n\/\/ \u6700\u6709\u53ef\u80fd\u53d1\u751f_pRoot \u4f4d\u7f6e\u5c31\u662f P \u548c G &#xff0c;\u5176\u4e2d G \u6539\u53d8\u53ea\u662f\u5176\u4e2d\u4e2a\u522b\u4f4d\u7f6e&#xff0c;\u5bf9_pRoot \u6ca1\u6709\u5f71\u54cd\u4e0b<br \/>\n\/\/ \u5176\u4e2d\u8981\u5173\u6ce8\u5c31\u662f _pRoot \u7684 P \u4f4d\u7f6e \u548c C \u4f4d\u7f6e<\/p>\n<p>Node* Child &#061; pParent-&gt;_pLeft;\/\/C<br \/>\nNode* Parent &#061; pParent;\/\/P<br \/>\nNode* GrandParent &#061; pParent-&gt;_pParent;\/\/G<\/p>\n<p>\/\/ 4 \u6bb5\u4ee3\u7801\u7ef4\u62a4<br \/>\n\/\/ P-&gt;C &#061; P-&gt;R<br \/>\nParent-&gt;_pLeft &#061; Child-&gt;_pRight;<br \/>\n\/\/ R-&gt;P &#061; R-&gt;P<br \/>\nif (Child-&gt;_pRight !&#061; nullptr)<br \/>\n{<br \/>\nChild-&gt;_pRight-&gt;_pParent &#061; Parent;<br \/>\n}<br \/>\n\/\/ C-&gt;R &#061; C-&gt;P<br \/>\nChild-&gt;_pRight &#061; Parent;<br \/>\n\/\/ P-&gt;G &#061; P-&gt;C<br \/>\nParent-&gt;_pParent &#061; Child;<br \/>\n\/\/ G-&gt;P &#061; G-&gt;C<br \/>\nif (GrandParent !&#061; nullptr)<br \/>\n{<br \/>\nGrandParent-&gt;_pLeft &#061;&#061; Parent ? GrandParent-&gt;_pLeft &#061; Child : GrandParent-&gt;_pRight &#061; Child;<br \/>\n\/\/ C-&gt;P &#061; C-&gt;G<br \/>\nChild-&gt;_pParent &#061; GrandParent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\/\/ C-&gt;P &#061; C-&gt;nullptr<br \/>\nChild-&gt;_pParent &#061; nullptr;<br \/>\n_pRoot &#061; Child;<br \/>\n}<br \/>\n\/\/ \u8c03\u6574\u5e73\u8861<br \/>\nBf(Parent);<br \/>\nBf(Child);<br \/>\n}<\/p>\n<p>2.3.3 \u5de6\u5355\u65cb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"993\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135703-6ae7452ff3372.png\" width=\"2019\" \/><\/p>\n<p>\/\/ \u5de6\u5355\u65cb<br \/>\nvoid RotateL(Node* pParent)<br \/>\n{   \/\/  G       G<br \/>\n\/\/   P         C<br \/>\n\/\/    C  -&gt;  P   R<br \/>\n\/\/   L R      L<br \/>\n\/\/ pParent -&gt; P<br \/>\n\/\/ \u6700\u6709\u53ef\u80fd\u53d1\u751f_pRoot \u4f4d\u7f6e\u5c31\u662f P \u548c G &#xff0c;\u5176\u4e2d G \u6539\u53d8\u53ea\u662f\u5176\u4e2d\u4e2a\u522b\u4f4d\u7f6e&#xff0c;\u5bf9_pRoot \u6ca1\u6709\u5f71\u54cd\u4e0b<br \/>\n\/\/ \u5176\u4e2d\u8981\u5173\u6ce8\u5c31\u662f _pRoot \u7684 P \u4f4d\u7f6e \u548c C \u4f4d\u7f6e<br \/>\n\/\/ 4 \u6bb5\u4ee3\u7801\u7ef4\u62a4<br \/>\n\/\/ P-&gt;C &#061; P-&gt;L<\/p>\n<p>Node* Child &#061; pParent-&gt;_pRight;\/\/C<br \/>\nNode* Parent &#061; pParent;\/\/P<br \/>\nNode* GrandParent &#061; pParent-&gt;_pParent;\/\/G<br \/>\n\/\/ 4 \u6bb5\u4ee3\u7801\u7ef4\u62a4<br \/>\n\/\/ P-&gt;C &#061; P-&gt;L<br \/>\nParent-&gt;_pRight &#061; Child-&gt;_pLeft;<br \/>\n\/\/ L-&gt;C &#061; L-&gt;P<br \/>\nif (Child-&gt;_pLeft !&#061; nullptr)<br \/>\n{<br \/>\nChild-&gt;_pLeft-&gt;_pParent &#061; Parent;<br \/>\n}<br \/>\n\/\/ C-&gt;L &#061; C-&gt;P<br \/>\nChild-&gt;_pLeft &#061; Parent;<br \/>\n\/\/ P-&gt;G &#061; P-&gt;C<br \/>\nParent-&gt;_pParent &#061; Child;<br \/>\nif (GrandParent !&#061; nullptr)<br \/>\n{<br \/>\n\/\/ G-&gt;P &#061; G-&gt;C<br \/>\nGrandParent-&gt;_pLeft &#061;&#061; Parent ? GrandParent-&gt;_pLeft &#061; Child : GrandParent-&gt;_pRight &#061; Child;<br \/>\n\/\/ C-&gt;P &#061; C-&gt;G<br \/>\nChild-&gt;_pParent &#061; GrandParent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\/\/ C-&gt;P &#061; C-&gt;nullptr<br \/>\nChild-&gt;_pParent &#061; nullptr;<br \/>\n_pRoot &#061; Child;<br \/>\n}<br \/>\n\/\/ \u8c03\u6574\u5e73\u8861<br \/>\nBf(Parent);<br \/>\nBf(Child);<br \/>\n} <\/p>\n<p>2.3.4 \u5de6\u53f3\u53cc\u65cb<\/p>\n<p>\u5728\u90e8\u5206\u60c5\u51b5\u79cd\u5355\u65cb\u5df2\u7ecf\u6ca1\u6709\u529e\u6cd5\u6ee1\u8db3\u4e86\u6240\u6709\u9700\u8981\u53cc\u65cb\u6765\u6ee1\u8db3&#xff0c;\u7b2c\u4e00\u6b21\u65cb\u8f6c\u662f\u4e3a\u4e86\u7ed3\u6784\u53d8\u6210&#xff0c;\u7b26\u5408\u5de6\u53f3\u5355\u65cb\u7684\u7ed3\u6784\u3002\u5176\u6b21\u53cc\u65cb\u53ef\u4ee5\u590d\u7528\u524d\u9762\u7684\u4ee3\u7801&#xff0c;\u4ee5\u4fbf\u4e8e\u7406\u89e3\u4e5f\u53ef\u4ee5\u4e0d\u7528\u5199\u592a\u591a\u4ee3\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"637\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135704-6ae74530940e7.png\" width=\"1911\" \/><\/p>\n<p>\/\/ \u5de6\u53f3\u53cc\u65cb<br \/>\n    void RotateLR(Node* pParent)<br \/>\n{<br \/>\n\/*<br \/>\n   a   a         c<br \/>\n b   -&gt;  c-&gt; b   a<br \/>\n  c    b<br \/>\nb-&gt;pParent<br \/>\n\u4f18\u5148 c \u8fdb\u884c \u5de6\u65cb<br \/>\n\u56e0\u4e3a c \u8fdb\u884c \u53f3\u65cb<br \/>\n*\/<br \/>\nRotateL(pParent-&gt;_pLeft);<br \/>\nRotateR(pParent);<br \/>\n} <\/p>\n<p>2.3.5 \u53f3\u5de6\u53cc\u65cb<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"720\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135705-6ae7453102f60.png\" width=\"1965\" \/><\/p>\n<p>\/\/ \u53f3\u5de6\u53cc\u65cb<br \/>\nvoid RotateRL(Node* pParent)<br \/>\n{\/\/ pParent -&gt; a<br \/>\n\/*<br \/>\na      a c<br \/>\n  b   -&gt;    c-&gt; b   a<br \/>\n c         b<br \/>\nb-&gt;pParent<br \/>\n\u4f18\u5148 c \u8fdb\u884c \u53f3\u65cb<br \/>\n\u56e0\u4e3a c \u8fdb\u884c \u5de6\u65cb<br \/>\n*\/<br \/>\nRotateR(pParent-&gt;_pRight);<br \/>\nRotateL(pParent);<br \/>\n} <\/p>\n<h3 id=\"2.4%20AVL%20%E6%A0%91%E7%9A%84%E6%9F%A5%E6%89%BE\">2.4 AVL \u6811\u7684\u67e5\u627e<\/h3>\n<p>AVL \u6811\u7684\u67e5\u627e\u8fc7\u7a0b\u548c\u666e\u901a\u4e8c\u53c9\u641c\u7d22\u6811\u67e5\u627e\u903b\u8f91\u4e00\u81f4\u3002\u4ece\u6839\u8282\u70b9\u51fa\u53d1&#xff0c;\u62ff\u76ee\u6807\u503c\u548c\u5f53\u524d\u8282\u70b9\u6bd4\u8f83&#xff1a;\u76ee\u6807\u66f4\u5c0f\u5c31\u53bb\u5f80\u5de6\u5b50\u6811\u67e5\u627e&#xff0c;\u76ee\u6807\u66f4\u5927\u5c31\u53bb\u5f80\u53f3\u5b50\u6811\u67e5\u627e&#xff0c;\u76f8\u7b49\u5219\u67e5\u627e\u6210\u529f\u3002\u5982\u679c\u8d70\u5230\u7a7a\u8282\u70b9&#xff0c;\u4ee3\u8868\u67e5\u627e\u5931\u8d25\u3002 \u533a\u522b\u5728\u4e8e AVL \u6811\u53d7\u5e73\u8861\u7ea6\u675f\u9650\u5236&#xff0c;\u6811\u9ad8\u7a33\u5b9a\u4e3a logn&#xff0c;\u67e5\u627e\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u662f O (log n)&#xff0c;\u4e0d\u4f1a\u50cf\u666e\u901a BST \u90a3\u6837\u9000\u5316\u6210 O (n)\u3002\u67e5\u627e\u8fc7\u7a0b\u4e0d\u4f1a\u4fee\u6539\u6811\u7ed3\u6784\u3001\u4e0d\u6539\u52a8\u9ad8\u5ea6\u548c\u5e73\u8861\u56e0\u5b50&#xff0c;\u4e5f\u4e0d\u4f1a\u89e6\u53d1\u65cb\u8f6c\u3002<\/p>\n<h3 id=\"2.5%20AVL%20%E6%A0%91%E7%9A%84%E5%B9%B3%E8%A1%A1%E6%A3%80%E6%9F%A5\">2.5 AVL \u6811\u7684\u5e73\u8861\u68c0\u67e5<\/h3>\n<p>\/\/ AVL\u6811\u7684\u9a8c\u8bc1<br \/>\nbool IsAVLTree()<br \/>\n{<br \/>\nreturn _IsAVLTree(_pRoot);<br \/>\n}<br \/>\nprivate:<br \/>\n    \/\/ \u6839\u636eAVL\u6811\u7684\u6982\u5ff5\u9a8c\u8bc1pRoot\u662f\u5426\u4e3a\u6709\u6548\u7684AVL\u6811<br \/>\nbool _IsAVLTree(Node* pRoot)<br \/>\n{<br \/>\nif (pRoot &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn true;<br \/>\n}<br \/>\nbool put &#061; _IsAVLTree(pRoot-&gt;_pLeft);<br \/>\nif (put &#061;&#061; false || abs(pRoot-&gt;_bf) &gt;&#061; 2)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;\u8282\u70b9\u5e73\u8861\u5f02\u5e38&#034; &lt;&lt; endl;<\/p>\n<p>return false;<br \/>\n}<br \/>\nput &#061; _IsAVLTree(pRoot-&gt;_pRight);<br \/>\nreturn put;<br \/>\n} <\/p>\n<h3 id=\"2.6%20AVL%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4\">2.6 AVL\u6811\u7684\u5220\u9664<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"485\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135705-6ae7453177685.png\" width=\"1255\" \/><\/p>\n<p>\u5220\u9664\u7684\u539f\u7406\u5176\u5b9e\u4e0e\u63d2\u5165\u7684\u539f\u7406\u4e00\u81f4&#xff0c;\u7531\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u5220\u9664\u539f\u7406&#xff0c;\u5728\u52a0\u4e0a\u5bf9\u5e94\u4f4d\u7f6e\u65cb\u8f6c\u64cd\u4f5c\u5373\u53ef\u3002<\/p>\n<p>AVLTree \u00b7 \u6d6a\u5b50\u00b7\u60a0\u4ec1\/C&#043;&#043; \u77e5\u8bc6\u5e93 &#8211; \u7801\u4e91 &#8211; \u5f00\u6e90\u4e2d\u56fd<\/p>\n<hr \/>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"436\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135705-6ae74531ab89a.jpg\" width=\"652\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n1. AVL\u7684\u6982\u5ff5\u200b\u7f16\u8f91<br \/>\n2. AVL \u6811\u7684\u5b9e\u73b0<br \/>\n2.1 AVL \u6811\u7684\u7ed3\u6784<br \/>\n2.2 AVL \u6811\u7684\u63d2\u5165<br \/>\n2.3 \u65cb\u8f6c<br \/>\n2.4 AVL \u6811\u7684\u67e5\u627e<br \/>\n2.5 AVL \u6811\u7684\u5e73\u8861\u68c0\u67e5<br \/>\n2.6 AVL\u6811\u7684\u5220\u9664 1. AVL\u7684\u6982\u5ff5<br \/>\nAVL \u6811\u7531\u524d\u82cf\u8054\u6570\u5b66\u5bb6 G.M. Adelson-Velsky&#xff08;\u963f\u5fb7\u5c14\u68ee &#8211; \u97e6\u5c14\u65af\u57fa&#xff09; \u548c E.M. Landis&#xff08;\u5170\u8fea\u65af&#xff09; \u5728 1962 \u5e74\u63d0\u51fa\u5e76\u53d1\u8868\u8bba\u6587&#xff0c;\u5b83\u4e5f\u662f\u4e16<\/p>\n","protected":false},"author":2,"featured_media":120969,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55],"topic":[],"class_list":["post-120976","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/120976.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 1. AVL\u7684\u6982\u5ff5\u200b\u7f16\u8f91 2. AVL \u6811\u7684\u5b9e\u73b0 2.1 AVL \u6811\u7684\u7ed3\u6784 2.2 AVL \u6811\u7684\u63d2\u5165 2.3 \u65cb\u8f6c 2.4 AVL \u6811\u7684\u67e5\u627e 2.5 AVL \u6811\u7684\u5e73\u8861\u68c0\u67e5 2.6 AVL\u6811\u7684\u5220\u9664 1. AVL\u7684\u6982\u5ff5 AVL \u6811\u7531\u524d\u82cf\u8054\u6570\u5b66\u5bb6 G.M. Adelson-Velsky&#xff08;\u963f\u5fb7\u5c14\u68ee - \u97e6\u5c14\u65af\u57fa&#xff09; \u548c E.M. Landis&#xff08;\u5170\u8fea\u65af&#xff09; \u5728 1962 \u5e74\u63d0\u51fa\u5e76\u53d1\u8868\u8bba\u6587&#xff0c;\u5b83\u4e5f\u662f\u4e16\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/120976.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-01T13:57:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135703-6ae7452f6be06.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120976.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/120976.html\",\"name\":\"\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-01T13:57:06+00:00\",\"dateModified\":\"2026-11-01T13:57:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/120976.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/120976.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/120976.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010C++\u3011AVL \u6811\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/120976.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 1. AVL\u7684\u6982\u5ff5\u200b\u7f16\u8f91 2. AVL \u6811\u7684\u5b9e\u73b0 2.1 AVL \u6811\u7684\u7ed3\u6784 2.2 AVL \u6811\u7684\u63d2\u5165 2.3 \u65cb\u8f6c 2.4 AVL \u6811\u7684\u67e5\u627e 2.5 AVL \u6811\u7684\u5e73\u8861\u68c0\u67e5 2.6 AVL\u6811\u7684\u5220\u9664 1. AVL\u7684\u6982\u5ff5 AVL \u6811\u7531\u524d\u82cf\u8054\u6570\u5b66\u5bb6 G.M. Adelson-Velsky&#xff08;\u963f\u5fb7\u5c14\u68ee - \u97e6\u5c14\u65af\u57fa&#xff09; \u548c E.M. Landis&#xff08;\u5170\u8fea\u65af&#xff09; \u5728 1962 \u5e74\u63d0\u51fa\u5e76\u53d1\u8868\u8bba\u6587&#xff0c;\u5b83\u4e5f\u662f\u4e16","og_url":"https:\/\/www.wsisp.com\/helps\/120976.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-01T13:57:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261101135703-6ae7452f6be06.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/120976.html","url":"https:\/\/www.wsisp.com\/helps\/120976.html","name":"\u3010C++\u3011AVL \u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-01T13:57:06+00:00","dateModified":"2026-11-01T13:57:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/120976.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/120976.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/120976.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010C++\u3011AVL \u6811"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=120976"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/120976\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/120969"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=120976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=120976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=120976"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=120976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}