{"id":50973,"date":"2025-08-10T15:24:23","date_gmt":"2025-08-10T07:24:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/50973.html"},"modified":"2025-08-10T15:24:23","modified_gmt":"2025-08-10T07:24:23","slug":"%e7%ac%ac%e5%8d%81%e5%85%ad%e8%ae%b2%ef%bc%9aavl%e6%a0%91%e5%92%8c%e7%ba%a2%e9%bb%91%e6%a0%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/50973.html","title":{"rendered":"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\u6811"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"1%E3%80%81%E5%BA%95%E5%B1%82%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">1\u3001\u5e95\u5c42\u7ed3\u6784<\/p>\n<p id=\"2%E3%80%81AVL%E6%A0%91-toc\" style=\"margin-left:40px\">2\u3001AVL\u6811<\/p>\n<p id=\"2.1%E3%80%81%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">2.1\u3001\u6982\u5ff5<\/p>\n<p id=\"2.2%E3%80%81AVL%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5-toc\" style=\"margin-left:80px\">2.2\u3001AVL\u6811\u7684\u63d2\u5165<\/p>\n<p id=\"2.2.1%E3%80%81%E5%8F%B3%E5%8D%95%E6%97%8B-toc\" style=\"margin-left:120px\">2.2.1\u3001\u53f3\u5355\u65cb<\/p>\n<p id=\"2.2.2%E3%80%81%E5%B7%A6%E5%8D%95%E6%97%8B-toc\" style=\"margin-left:120px\">2.2.2\u3001\u5de6\u5355\u65cb<\/p>\n<p id=\"2.2.3%E3%80%81%E5%B7%A6%E5%8F%B3%E5%8D%95%E6%97%8B-toc\" style=\"margin-left:120px\">2.2.3\u3001\u5de6\u53f3\u5355\u65cb<\/p>\n<p id=\"2.2.4%E3%80%81%E5%8F%B3%E5%B7%A6%E5%8D%95%E6%97%8B-toc\" style=\"margin-left:120px\">2.2.4\u3001\u53f3\u5de6\u5355\u65cb<\/p>\n<p id=\"2.3%E3%80%81AVL%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4-toc\" style=\"margin-left:80px\">2.3\u3001AVL\u6811\u7684\u5220\u9664<\/p>\n<p id=\"2.4%E3%80%81AVL%E6%A0%91%E7%9A%84%E6%80%A7%E8%83%BD-toc\" style=\"margin-left:80px\">2.4\u3001AVL\u6811\u7684\u6027\u80fd<\/p>\n<p id=\"2.5%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:80px\">2.5\u3001\u6a21\u62df\u5b9e\u73b0<\/p>\n<p id=\"3%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91-toc\" style=\"margin-left:40px\">3\u3001\u7ea2\u9ed1\u6811<\/p>\n<p id=\"3.1%E3%80%81%E6%A6%82%E5%BF%B5-toc\" style=\"margin-left:80px\">3.1\u3001\u6982\u5ff5<\/p>\n<p id=\"3.2%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5-toc\" style=\"margin-left:80px\">3.2\u3001\u7ea2\u9ed1\u6811\u7684\u63d2\u5165<\/p>\n<p id=\"3.2.1%E3%80%81%E6%83%85%E5%86%B5%E4%B8%80-toc\" style=\"margin-left:120px\">3.2.1\u3001\u60c5\u51b5\u4e00<\/p>\n<p id=\"3.2.2%E3%80%81%E6%83%85%E5%86%B5%E4%BA%8C-toc\" style=\"margin-left:120px\">3.2.2\u3001\u60c5\u51b5\u4e8c<\/p>\n<p id=\"3.2.3%E3%80%81%E6%83%85%E5%86%B5%E4%B8%89-toc\" style=\"margin-left:120px\">3.2.3\u3001\u60c5\u51b5\u4e09<\/p>\n<p id=\"3.3%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4-toc\" style=\"margin-left:80px\">3.3\u3001\u7ea2\u9ed1\u6811\u7684\u5220\u9664<\/p>\n<p id=\"3.4%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E6%80%A7%E8%83%BD-toc\" style=\"margin-left:80px\">3.4\u3001\u7ea2\u9ed1\u6811\u7684\u6027\u80fd<\/p>\n<p id=\"3.5%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:80px\">3.5\u3001\u6a21\u62df\u5b9e\u73b0<\/p>\n<p id=\"4%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0map%E5%92%8Cset-toc\" style=\"margin-left:40px\">4\u3001\u6a21\u62df\u5b9e\u73b0map\u548cset<\/p>\n<hr id=\"hr-toc\" \/>\n<h3 id=\"1%E3%80%81%E5%BA%95%E5%B1%82%E7%BB%93%E6%9E%84\">1\u3001\u5e95\u5c42\u7ed3\u6784<\/h3>\n<p>\u524d\u9762\u5bf9map\u3001multimap\u3001set\u4ee5\u53camultiset\u8fdb\u884c\u4e86\u7b80\u5355\u7684\u4ecb\u7ecd&#xff0c;\u8fd9\u51e0\u4e2a\u5bb9\u5668\u6709\u4e2a\u5171\u540c\u70b9\u662f&#xff1a;\u5176\u5e95\u5c42\u90fd\u662f\u6309\u7167\u4e8c\u53c9\u641c\u7d22\u6811\u6765\u5b9e\u73b0\u7684&#xff0c;\u4f46\u662f\u4e8c\u53c9\u641c\u7d22\u6811\u6709\u5176\u81ea\u8eab\u7684\u7f3a\u9677&#xff0c;\u5047\u5982\u5f80\u6811\u4e2d\u63d2\u5165\u7684\u5143\u7d20\u6709\u5e8f\u6216\u8005\u63a5\u8fd1\u6709\u5e8f&#xff0c;\u4e8c\u53c9\u641c\u7d22\u6811\u5c31\u4f1a\u9000\u5316\u6210\u5355\u652f\u6811&#xff0c;\u65f6\u95f4\u590d\u6742\u5ea6\u4f1a\u9000\u5316\u6210O(N)&#xff0c;\u56e0\u6b64 map\u3001set\u7b49\u5173\u8054\u5f0f\u5bb9\u5668\u7684\u5e95\u5c42\u7ed3\u6784\u662f\u5bf9\u4e8c\u53c9\u6811\u8fdb\u884c\u4e86\u5e73\u8861\u5904\u7406&#xff0c;\u5373\u91c7\u7528\u7ea2\u9ed1\u6811\u6765\u5b9e\u73b0\u3002<\/p>\n<h3 id=\"2%E3%80%81AVL%E6%A0%91\">2\u3001AVL\u6811<\/h3>\n<h4 id=\"2.1%E3%80%81%E6%A6%82%E5%BF%B5\">2.1\u3001\u6982\u5ff5<\/h4>\n<p>\u4e8c\u53c9\u641c\u7d22\u6811\u867d\u53ef\u4ee5\u7f29\u77ed\u67e5\u627e\u7684\u6548\u7387&#xff0c;\u4f46\u5982\u679c\u6570\u636e\u6709\u5e8f\u6216\u63a5\u8fd1\u6709\u5e8f\u4e8c\u53c9\u641c\u7d22\u6811\u5c06\u9000\u5316\u4e3a\u5355\u652f\u6811&#xff0c;\u67e5 \u627e\u5143\u7d20\u76f8\u5f53\u4e8e\u5728\u987a\u5e8f\u8868\u4e2d\u641c\u7d22\u5143\u7d20&#xff0c;\u6548\u7387\u4f4e\u4e0b\u3002\u56e0\u6b64&#xff0c;\u4e24\u4f4d\u4fc4\u7f57\u65af\u7684\u6570\u5b66\u5bb6G.M.Adelson-Velskii \u548cE.M.Landis\u57281962\u5e74\u53d1\u660e\u4e86\u4e00\u79cd\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\u7684\u65b9\u6cd5&#xff1a;\u5f53\u5411\u4e8c\u53c9\u641c\u7d22\u6811\u4e2d\u63d2\u5165\u65b0\u7ed3\u70b9\u540e&#xff0c;\u5982\u679c\u80fd\u4fdd\u8bc1\u6bcf\u4e2a\u7ed3\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u4e4b\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71(\u9700\u8981\u5bf9\u6811\u4e2d\u7684\u7ed3\u70b9\u8fdb\u884c\u8c03\u6574)&#xff0c;\u5373\u53ef\u964d\u4f4e\u6811\u7684\u9ad8\u5ea6&#xff0c;\u4ece\u800c\u51cf\u5c11\u5e73\u5747\u641c\u7d22\u957f\u5ea6\u3002<\/p>\n<p>\u4e00\u68f5AVL\u6811\u6216\u8005\u662f\u7a7a\u6811&#xff0c;\u6216\u8005\u662f\u5177\u6709\u4ee5\u4e0b\u6027\u8d28\u7684\u4e8c\u53c9\u641c\u7d22\u6811&#xff1a;<\/p>\n<p>1\u3001\u5b83\u7684\u5de6\u53f3\u5b50\u6811\u90fd\u662fAVL\u6811\u3002<\/p>\n<p>2\u3001\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u4e4b\u5dee(\u7b80\u79f0\u5e73\u8861\u56e0\u5b50)\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"299\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-689849258e514.png\" width=\"460\" \/><\/p>\n<p>\u5982\u679c\u4e00\u68f5\u4e8c\u53c9\u641c\u7d22\u6811\u662f\u9ad8\u5ea6\u5e73\u8861\u7684&#xff0c;\u5b83\u5c31\u662fAVL\u6811\u3002\u5982\u679c\u5b83\u6709n\u4e2a\u7ed3\u70b9&#xff0c;\u641c\u7d22\u65f6\u95f4\u590d\u6742\u5ea6O(logN)\u3002<\/p>\n<h4 id=\"2.2%E3%80%81AVL%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5\">2.2\u3001AVL\u6811\u7684\u63d2\u5165<\/h4>\n<p>AVL\u6811\u5c31\u662f\u5728\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u57fa\u7840\u4e0a\u5f15\u5165\u4e86\u5e73\u8861\u56e0\u5b50&#xff0c;\u56e0\u6b64AVL\u6811\u4e5f\u53ef\u4ee5\u770b\u6210\u662f\u4e8c\u53c9\u641c\u7d22\u6811\u3002AVL\u6811\u7684\u63d2\u5165\u8fc7\u7a0b\u53ef\u4ee5\u5206\u4e3a\u4e24\u6b65&#xff1a;<\/p>\n<p>1\u3001\u6309\u7167\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u65b9\u5f0f\u63d2\u5165\u65b0\u8282\u70b9\u3002<\/p>\n<p>2\u3001\u8c03\u6574\u8282\u70b9\u7684\u5e73\u8861\u56e0\u5b50\u3002<\/p>\n<p>\u5982\u679c\u5728\u4e00\u68f5\u539f\u672c\u662f\u5e73\u8861\u7684AVL\u6811\u4e2d\u63d2\u5165\u4e00\u4e2a\u65b0\u8282\u70b9&#xff0c;\u53ef\u80fd\u9020\u6210\u4e0d\u5e73\u8861&#xff0c;\u6b64\u65f6\u5fc5\u987b\u8c03\u6574\u6811\u7684\u7ed3\u6784&#xff0c; \u4f7f\u4e4b\u5e73\u8861\u5316\u3002\u6839\u636e\u8282\u70b9\u63d2\u5165\u4f4d\u7f6e\u7684\u4e0d\u540c&#xff0c;AVL\u6811\u7684\u65cb\u8f6c\u5206\u4e3a\u56db\u79cd\u4ee5\u4e0b\u56db\u79cd&#xff1a;\u5206\u522b\u4e3a\u53f3\u5355\u65cb\u3001\u5de6\u5355\u65cb\u3001\u5de6\u53f3\u5355\u65cb\u3001\u53f3\u5de6\u5355\u65cb\u3002<\/p>\n<h5 id=\"2.2.1%E3%80%81%E5%8F%B3%E5%8D%95%E6%97%8B\">2.2.1\u3001\u53f3\u5355\u65cb<\/h5>\n<p>\u65b0\u8282\u70b9\u63d2\u5165\u8f83\u9ad8\u5de6\u5b50\u6811\u7684\u5de6\u4fa7&#xff08;\u5de6\u5de6&#xff09;&#xff1a;\u53f3\u5355\u65cb<\/p>\n<p>\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"205\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-68984925a1fc6.png\" width=\"833\" \/><\/p>\n<p>\u5176\u4e2d&#xff0c;a\u3001b\u3001c\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah\u7684AVL\u6811&#xff0c;h\u5927\u4e8e\u7b49\u4e8e0\u3002<\/p>\n<p>\u5373&#xff1a;\u5bf960\u8fdb\u884c\u53f3\u5355\u65cb&#xff0c;\u65cb\u8f6c\u5b8c\u6210\u540e\u518d\u8003\u8651\u5e73\u8861\u56e0\u5b50\u7684\u66f4\u65b0\u3002<\/p>\n<h5 id=\"2.2.2%E3%80%81%E5%B7%A6%E5%8D%95%E6%97%8B\">2.2.2\u3001\u5de6\u5355\u65cb<\/h5>\n<p>\u65b0\u8282\u70b9\u63d2\u5165\u8f83\u9ad8\u53f3\u5b50\u6811\u7684\u53f3\u4fa7&#xff08;\u53f3\u53f3&#xff09;&#xff1a;\u5de6\u5355\u65cb<\/p>\n<p>\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-68984925b5d43.png\" width=\"799\" \/><\/p>\n<p>\u5176\u4e2d&#xff0c;a\u3001b\u3001c\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah\u7684AVL\u6811&#xff0c;h\u5927\u4e8e\u7b49\u4e8e0\u3002<\/p>\n<p>\u5373&#xff1a;\u5bf930\u8fdb\u884c\u5de6\u5355\u65cb&#xff0c;\u65cb\u8f6c\u5b8c\u6210\u540e\u518d\u8003\u8651\u5e73\u8861\u56e0\u5b50\u7684\u66f4\u65b0\u3002<\/p>\n<h5 id=\"2.2.3%E3%80%81%E5%B7%A6%E5%8F%B3%E5%8D%95%E6%97%8B\">2.2.3\u3001\u5de6\u53f3\u5355\u65cb<\/h5>\n<p>\u65b0\u8282\u70b9\u63d2\u5165\u8f83\u9ad8\u5de6\u5b50\u6811\u7684\u53f3\u4fa7&#xff08;\u5de6\u53f3&#xff09;&#xff1a;\u5148\u5de6\u5355\u65cb\u518d\u53f3\u5355\u65cb<\/p>\n<p>\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"476\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-68984925cba03.png\" width=\"731\" \/><\/p>\n<p>\u5176\u4e2d&#xff0c;a\u3001d\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah\u7684AVL\u6811&#xff0c;b\u3001c\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah-1\u7684AVL\u6811&#xff0c;h\u5927\u4e8e\u7b49\u4e8e0\u3002\u5982\u679ch&#061;0&#xff0c;60\u8fd9\u4e2a\u7ed3\u70b9\u5373\u662f\u65b0\u589e\u7684\u7ed3\u70b9\u3002<\/p>\n<p>\u5373&#xff1a;\u5148\u5bf930\u8fdb\u884c\u5de6\u5355\u65cb&#xff0c;\u7136\u540e\u518d\u5bf990\u8fdb\u884c\u53f3\u5355\u65cb&#xff0c;\u65cb\u8f6c\u5b8c\u6210\u540e\u518d\u8003\u8651\u5e73\u8861\u56e0\u5b50\u7684\u66f4\u65b0\u3002<\/p>\n<h5 id=\"2.2.4%E3%80%81%E5%8F%B3%E5%B7%A6%E5%8D%95%E6%97%8B\">2.2.4\u3001\u53f3\u5de6\u5355\u65cb<\/h5>\n<p>\u65b0\u8282\u70b9\u63d2\u5165\u8f83\u9ad8\u53f3\u5b50\u6811\u7684\u5de6\u4fa7&#xff08;\u53f3\u5de6&#xff09;&#xff1a;\u5148\u53f3\u5355\u65cb\u518d\u5de6\u5355\u65cb<\/p>\n<p>\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"577\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-68984925def37.png\" width=\"726\" \/><\/p>\n<p>\u5176\u4e2d&#xff0c;a\u3001d\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah\u7684AVL\u6811&#xff0c;b\u3001c\u5206\u522b\u4e3a\u9ad8\u5ea6\u4e3ah-1\u7684AVL\u6811&#xff0c;h\u5927\u4e8e\u7b49\u4e8e0\u3002\u5982\u679ch&#061;0&#xff0c;60\u8fd9\u4e2a\u7ed3\u70b9\u5373\u662f\u65b0\u589e\u7684\u7ed3\u70b9\u3002<\/p>\n<p>\u5373&#xff1a;\u5148\u5bf990\u8fdb\u884c\u53f3\u5355\u65cb&#xff0c;\u518d\u5bf930\u8fdb\u884c\u5de6\u5355\u65cb&#xff0c;\u65cb\u8f6c\u5b8c\u6210\u540e\u518d\u8003\u8651\u5e73\u8861\u56e0\u5b50\u7684\u66f4\u65b0\u3002<\/p>\n<h4 id=\"2.3%E3%80%81AVL%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4\">2.3\u3001AVL\u6811\u7684\u5220\u9664<\/h4>\n<p>\u5220\u9664\u6bd4\u63d2\u5165\u8fd8\u8981\u590d\u6742&#xff0c;\u5177\u4f53\u5b9e\u73b0\u53ef\u53c2\u8003\u300a\u7b97\u6cd5\u5bfc\u8bba\u300b\u6216\u300a\u6570\u636e\u7ed3\u6784&#xff08;\u7528\u9762\u5411\u5bf9\u8c61\u65b9\u6cd5\u4e0eC&#043;&#043;\u63cf\u8ff0&#xff09;\u300b\u6bb7\u4eba\u6606\u7248\u3002<\/p>\n<h4 id=\"2.4%E3%80%81AVL%E6%A0%91%E7%9A%84%E6%80%A7%E8%83%BD\">2.4\u3001AVL\u6811\u7684\u6027\u80fd<\/h4>\n<p>AVL\u6811\u662f\u4e00\u68f5\u7edd\u5bf9\u5e73\u8861\u7684\u4e8c\u53c9\u641c\u7d22\u6811&#xff0c;\u5176\u8981\u6c42\u6bcf\u4e2a\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u90fd\u4e0d\u8d85\u8fc71&#xff0c;\u8fd9 \u6837\u53ef\u4ee5\u4fdd\u8bc1\u67e5\u8be2\u65f6\u9ad8\u6548\u7684\u65f6\u95f4\u590d\u6742\u5ea6&#xff0c;\u5373O&#xff08;log\u00a0(N)&#xff09;\u3002<\/p>\n<h4 id=\"2.5%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0\">2.5\u3001\u6a21\u62df\u5b9e\u73b0<\/h4>\n<p>template&lt;class K, class V&gt;<br \/>\nstruct AVLTreeNode<br \/>\n{<br \/>\nAVLTreeNode(const pair&lt;K, V&gt;&amp; kv)<br \/>\n:_left(nullptr)<br \/>\n,_right(nullptr)<br \/>\n,_parent(nullptr)<br \/>\n,_kv(kv)<br \/>\n,_bf(0)<br \/>\n{}<\/p>\n<p>AVLTreeNode* _left;<br \/>\nAVLTreeNode* _right;<br \/>\nAVLTreeNode* _parent;<\/p>\n<p>pair&lt;K, V&gt; _kv;<br \/>\nint _bf; \/\/ \u5e73\u8861\u56e0\u5b50<br \/>\n};<\/p>\n<p>template&lt;class K, class V&gt;<br \/>\nclass AVLTree<br \/>\n{<br \/>\ntypedef AVLTreeNode&lt;K, V&gt; Node;<br \/>\npublic:<br \/>\nbool Insert(const pair&lt;K, V&gt;&amp; kv) \/\/ \u63d2\u5165<br \/>\n{<br \/>\nif (_root &#061;&#061; nullptr)<br \/>\n{<br \/>\n_root &#061; new Node(kv);<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>Node* parent &#061; nullptr;<br \/>\nNode* cur &#061; _root;<\/p>\n<p>while (cur)<br \/>\n{<br \/>\nif (cur-&gt;_kv.first &lt; kv.first)<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_right;<br \/>\n}<br \/>\nelse if (cur-&gt;_kv.first &gt; kv.first)<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<br \/>\n}<\/p>\n<p>cur &#061; new Node(kv);<br \/>\nif (parent-&gt;_kv.first &lt; kv.first)<br \/>\n{<br \/>\nparent-&gt;_right &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparent-&gt;_left &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<\/p>\n<p>\/*<br \/>\n* \u65b0\u7ed3\u70b9\u63d2\u5165\u540e&#xff0c;AVL\u6811\u7684\u5e73\u8861\u6027\u53ef\u80fd\u4f1a\u906d\u5230\u7834\u574f&#xff0c;\u6b64\u65f6\u5c31\u9700\u8981\u66f4\u65b0\u5e73\u8861\u56e0\u5b50&#xff0c;\u5e76\u68c0\u6d4b\u662f\u5426\u7834\u574f\u4e86AVL\u6811\u7684\u5e73\u8861\u6027\u3002<br \/>\n*<br \/>\n* cur\u63d2\u5165\u4e4b\u524d&#xff0c;parent\u7684\u5e73\u8861\u56e0\u5b50\u5206\u4e3a\u4ee5\u4e0b\u4e09\u79cd\u60c5\u51b5&#xff1a;-1&#xff0c;0&#xff0c;1\u3002<br \/>\n*<br \/>\n* 1\u3001\u5982\u679ccur\u63d2\u5165\u5230parent\u7684\u5de6\u4fa7&#xff0c;\u53ea\u9700\u8981\u7ed9parent\u7684\u5e73\u8861\u56e0\u5b50-1\u5373\u53ef\u3002<br \/>\n* 2\u3001\u5982\u679ccur\u63d2\u5165\u5230parent\u7684\u53f3\u4fa7&#xff0c;\u53ea\u9700\u8981\u7ed9parent\u7684\u5e73\u8861\u56e0\u5b50&#043;1\u5373\u53ef\u3002<br \/>\n*\/<\/p>\n<p>while (parent)<br \/>\n{<br \/>\n\/\/ \u4fee\u6539\u5e73\u8861\u56e0\u5b50<br \/>\nif (cur &#061;&#061; parent-&gt;_left)<br \/>\n{<br \/>\nparent-&gt;_bf&#8211;;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparent-&gt;_bf&#043;&#043;;<br \/>\n}<\/p>\n<p>\/*<br \/>\n* \u6b64\u65f6&#xff0c;parent\u7684\u5e73\u8861\u56e0\u5b50\u53ef\u80fd\u6709\u4e09\u79cd\u60c5\u51b5&#xff1a;0\u3001\u6b63\u8d1f1\u3001\u6b63\u8d1f2<br \/>\n*<br \/>\n* 1\u3001\u5982\u679cparent\u7684\u5e73\u8861\u56e0\u5b50\u4e3a0&#xff0c;\u8bf4\u660e\u63d2\u5165\u4e4b\u524dparent\u7684\u5e73\u8861\u56e0\u5b50\u4e3a\u6b63\u8d1f1&#xff0c;\u63d2\u5165\u540e\u88ab\u8c03\u6574\u62100&#xff0c;\u6b64\u65f6\u6ee1\u8db3AVL\u6811\u7684\u6027\u8d28&#xff0c;\u63d2\u5165\u6210\u529f\u3002<br \/>\n*    \u56e0\u4e3a\u65b0\u63d2\u5165\u7684\u7ed3\u70b9\u586b\u4e0a\u4e86\u4f4e\u7684\u90a3\u4e00\u8fb9&#xff0c;\u4e0d\u7528\u518d\u7ee7\u7eed\u5411\u4e0a\u66f4\u65b0\u3002<br \/>\n*<br \/>\n* 2\u3001\u5982\u679cparent\u7684\u5e73\u8861\u56e0\u5b50\u4e3a\u6b63\u8d1f1&#xff0c;\u8bf4\u660e\u63d2\u5165\u524dparent\u7684\u5e73\u8861\u56e0\u5b50\u4e00\u5b9a\u4e3a0&#xff0c;\u63d2\u5165\u540e\u88ab\u66f4\u65b0\u6210\u6b63\u8d1f1&#xff0c;\u6b64\u65f6\u4ee5parent\u4e3a\u6839\u7684\u6811<br \/>\n*    \u7684\u9ad8\u5ea6\u589e\u52a0&#xff0c;\u9700\u8981\u7ee7\u7eed\u5411\u4e0a\u66f4\u65b0\u3002<br \/>\n*<br \/>\n* 3\u3001\u5982\u679cparent\u7684\u5e73\u8861\u56e0\u5b50\u4e3a\u6b63\u8d1f2&#xff0c;\u5219parent\u7684\u5e73\u8861\u56e0\u5b50\u8fdd\u53cd\u5e73\u8861\u6811\u7684\u6027\u8d28&#xff0c;\u9700\u8981\u5bf9\u5176\u8fdb\u884c\u65cb\u8f6c\u5904\u7406\u3002<br \/>\n*\/<\/p>\n<p>if (parent-&gt;_bf &#061;&#061; 0) \/\/ \u5e73\u8861\u56e0\u5b50\u4e3a0&#xff0c;\u4e0d\u7528\u518d\u5411\u4e0a\u66f4\u65b0\u5e73\u8861\u56e0\u5b50\u3002<br \/>\n{<br \/>\nbreak;<br \/>\n}<br \/>\nelse if (parent-&gt;_bf &#061;&#061; 1 || parent-&gt;_bf &#061;&#061; -1) \/\/ \u5e73\u8861\u56e0\u5b50\u4e3a\u6b63\u8d1f1&#xff0c;\u5411\u4e0a\u8c03\u6574\u3002<br \/>\n{<br \/>\ncur &#061; parent;<br \/>\nparent &#061; parent-&gt;_parent;<br \/>\n}<br \/>\nelse if (parent-&gt;_bf &#061;&#061; 2 || parent-&gt;_bf &#061;&#061; -2) \/\/ \u5e73\u8861\u56e0\u5b50\u4e3a\u6b63\u8d1f2&#xff0c;\u56e0\u6b64\u9700\u8981\u505a\u65cb\u8f6c\u5904\u7406<br \/>\n{<br \/>\n\/\/ \u65cb\u8f6c&#xff0c;\u76ee\u7684\u662f\u4fdd\u6301\u6811\u7684\u5e73\u8861<br \/>\nif (parent-&gt;_bf &#061;&#061; 2 &amp;&amp; cur-&gt;_bf &#061;&#061; 1)<br \/>\n{<br \/>\nRotateL(parent); \/\/ \u5de6\u65cb<br \/>\n}<br \/>\nelse if (parent-&gt;_bf &#061;&#061; -2 &amp;&amp; cur-&gt;_bf &#061;&#061; -1)<br \/>\n{<br \/>\nRotateR(parent); \/\/ \u53f3\u65cb<br \/>\n}<br \/>\nelse if (parent-&gt;_bf &#061;&#061; 2 &amp;&amp; cur-&gt;_bf &#061;&#061; -1)<br \/>\n{<br \/>\nRotateRL(parent); \/\/ \u53f3\u5de6\u65cb<br \/>\n}<br \/>\nelse if (parent-&gt;_bf &#061;&#061; -2 &amp;&amp; cur-&gt;_bf &#061;&#061; 1)<br \/>\n{<br \/>\nRotateLR(parent); \/\/ \u5de6\u53f3\u65cb<br \/>\n}<\/p>\n<p>\/\/\u65cb\u8f6c\u5b8c\u6210\u540e&#xff0c;\u6811\u5df2\u7ecf\u5e73\u8861\u4e86\u3002<br \/>\nbreak;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nassert(false);<br \/>\n}<br \/>\n}<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>void RotateL(Node* parent) \/\/ \u5de6\u65cb<br \/>\n{<br \/>\nNode* subR &#061; parent-&gt;_right;<br \/>\nNode* subRL &#061; subR-&gt;_left;<\/p>\n<p>parent-&gt;_right &#061; subRL;<br \/>\nsubR-&gt;_left &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>parent-&gt;_parent &#061; subR;<br \/>\nif(subRL)<br \/>\nsubRL-&gt;_parent &#061; parent;<\/p>\n<p>if (_root &#061;&#061; parent)<br \/>\n{<br \/>\n_root &#061; subR;<br \/>\nsubR-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent)<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subR;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subR;<br \/>\n}<br \/>\nsubR-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\nparent-&gt;_bf &#061; subR-&gt;_bf &#061; 0;<br \/>\n}<\/p>\n<p>void RotateR(Node* parent) \/\/\u53f3\u65cb<br \/>\n{<br \/>\nNode* subL &#061; parent-&gt;_left;<br \/>\nNode* subLR &#061; subL-&gt;_right;<\/p>\n<p>parent-&gt;_left &#061; subLR;<br \/>\nif (subLR)   \/\/ subLR\u53ef\u80fd\u662f\u7a7a\u7684\u3002<br \/>\nsubLR-&gt;_parent &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>subL-&gt;_right &#061; parent;<br \/>\nparent-&gt;_parent &#061; subL;<\/p>\n<p>if (_root &#061;&#061; parent) \/\/ parent\u53ef\u80fd\u662f\u6839\u7ed3\u70b9\u3002<br \/>\n{<br \/>\n_root &#061; subL;<br \/>\nsubL-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse \/\/ parent\u4e0d\u662f\u6839\u7ed3\u70b9&#xff0c;\u662f\u5b50\u6811\u3002<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent) \/\/ \u662f\u5de6\u5b50\u6811<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subL;<br \/>\n}<br \/>\nelse \/\/ \u662f\u53f3\u5b50\u6811<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subL;<br \/>\n}<br \/>\nsubL-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\nsubL-&gt;_bf &#061; parent-&gt;_bf &#061; 0;<br \/>\n}<\/p>\n<p>void RotateRL(Node* parent) \/\/ \u53f3\u5de6\u65cb<br \/>\n{<br \/>\nNode* subR &#061; parent-&gt;_right;<br \/>\nNode* subRL &#061; subR-&gt;_left;<br \/>\nint bf &#061; subRL-&gt;_bf;<\/p>\n<p>RotateR(parent-&gt;_right);<br \/>\nRotateL(parent);<\/p>\n<p>if (bf &#061;&#061; 0) \/\/ subRL\u81ea\u5df1\u5c31\u662f\u65b0\u589e<br \/>\n{<br \/>\nparent-&gt;_bf &#061; subR-&gt;_bf &#061; subRL-&gt;_bf &#061; 0;<br \/>\n}<br \/>\nelse if (bf &#061;&#061; -1) \/\/ subRL\u7684\u5de6\u5b50\u6811\u65b0\u589e<br \/>\n{<br \/>\nparent-&gt;_bf &#061; 0;<br \/>\nsubRL-&gt;_bf &#061; 0;<br \/>\nsubR-&gt;_bf &#061; 1;<br \/>\n}<br \/>\nelse if (bf &#061;&#061; 1) \/\/ subRL\u7684\u53f3\u5b50\u6811\u65b0\u589e<br \/>\n{<br \/>\nparent-&gt;_bf &#061; -1;<br \/>\nsubRL-&gt;_bf &#061; 0;<br \/>\nsubR-&gt;_bf &#061; 0;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nassert(false);<br \/>\n}<br \/>\n}<\/p>\n<p>void RotateLR(Node* parent) \/\/ \u5de6\u53f3\u65cb<br \/>\n{<br \/>\nNode* subL &#061; parent-&gt;_left;<br \/>\nNode* subLR &#061; subL-&gt;_right;<br \/>\nint bf &#061; subLR-&gt;_bf;<\/p>\n<p>RotateL(parent-&gt;_left);<br \/>\nRotateR(parent);<\/p>\n<p>if (bf &#061;&#061; 0)<br \/>\n{<br \/>\nsubL-&gt;_bf &#061; subLR-&gt;_bf &#061; parent-&gt;_bf &#061; 0;<br \/>\n}<br \/>\nelse if (bf &#061;&#061; 1)<br \/>\n{<br \/>\nparent-&gt;_bf &#061; 0;<br \/>\nsubL-&gt;_bf &#061; -1;<br \/>\nsubLR-&gt;_bf &#061; 0;<br \/>\n}<br \/>\nelse if(bf &#061;&#061; -1)<br \/>\n{<br \/>\nparent-&gt;_bf &#061; 1;<br \/>\nsubL-&gt;_bf &#061; 0;<br \/>\nsubLR-&gt;_bf &#061; 0;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nassert(false);<br \/>\n}<br \/>\n}<\/p>\n<p>void InOrder() \/\/ \u4e2d\u5e8f\u904d\u5386<br \/>\n{<br \/>\n_InOrder(_root);<br \/>\ncout &lt;&lt; endl;<br \/>\n}<\/p>\n<p>bool IsBalance() \/\/ \u662f\u5426\u662f\u5e73\u8861\u6811<br \/>\n{<br \/>\nreturn _IsBalance(_root);<br \/>\n}<\/p>\n<p>int Height() \/\/ \u6811\u7684\u9ad8\u5ea6<br \/>\n{<br \/>\nreturn _Height(_root);<br \/>\n}<\/p>\n<p>size_t Size() \/\/ \u8fd4\u56de\u5143\u7d20\u4e2a\u6570<br \/>\n{<br \/>\nreturn _Size(_root);<br \/>\n}<\/p>\n<p>Node* Find(const K&amp; key) \/\/ \u67e5\u627e<br \/>\n{<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur)<br \/>\n{<br \/>\nif (cur-&gt;_kv.first &lt; key)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_right;<br \/>\n}<br \/>\nelse if (cur-&gt;_kv.first &gt; key)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn cur;<br \/>\n}<br \/>\n}<br \/>\nreturn NULL;<br \/>\n}<\/p>\n<p>private:<br \/>\nvoid _InOrder(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn;<br \/>\n_InOrder(root-&gt;_left);<br \/>\ncout &lt;&lt; root-&gt;_kv.first &lt;&lt; &#039;:&#039; &lt;&lt; root-&gt;_kv.second &lt;&lt; endl;;<br \/>\n_InOrder(root-&gt;_right);<br \/>\n}<\/p>\n<p>bool _IsBalance(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>int leftHeight &#061; _Height(root-&gt;_left);<br \/>\nint rightHeight &#061; _Height(root-&gt;_right);<\/p>\n<p>if (rightHeight &#8211; leftHeight !&#061; root-&gt;_bf)<br \/>\n{<br \/>\ncout &lt;&lt; root-&gt;_kv.first &lt;&lt; &#039;:&#039; &lt;&lt; root-&gt;_kv.second &lt;&lt; &#034; \u5e73\u8861\u56e0\u5b50\u5f02\u5e38&#034; &lt;&lt; endl;<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>return abs(rightHeight &#8211; leftHeight) &lt; 2<br \/>\n&amp;&amp; _IsBalance(root-&gt;_left)<br \/>\n&amp;&amp; _IsBalance(root-&gt;_right);<br \/>\n}<\/p>\n<p>int _Height(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn 0;<br \/>\nint leftHeight &#061; _Height(root-&gt;_left);<br \/>\nint rightHeight &#061; _Height(root-&gt;_right);<\/p>\n<p>return leftHeight &gt; rightHeight ? leftHeight &#043; 1 : rightHeight &#043; 1;<br \/>\n}<\/p>\n<p>size_t _Size(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn 0;<\/p>\n<p>return _Size(root-&gt;_left) &#043; _Size(root-&gt;_right) &#043; 1;<br \/>\n}<\/p>\n<p>private:<br \/>\nNode* _root &#061; nullptr;<br \/>\n}; <\/p>\n<h3 id=\"3%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91\">3\u3001\u7ea2\u9ed1\u6811<\/h3>\n<h4 id=\"3.1%E3%80%81%E6%A6%82%E5%BF%B5\">3.1\u3001\u6982\u5ff5<\/h4>\n<p>\u7ea2\u9ed1\u6811&#xff0c;\u662f\u4e00\u79cd\u4e8c\u53c9\u641c\u7d22\u6811&#xff0c;\u4f46\u5728\u6bcf\u4e2a\u7ed3\u70b9\u4e0a\u589e\u52a0\u4e00\u4e2a\u5b58\u50a8\u4f4d\u8868\u793a\u7ed3\u70b9\u7684\u989c\u8272&#xff0c;\u53ef\u4ee5\u662f\u9ed1\u8272\u6216\u8005\u662f\u7ea2\u8272\u3002 \u901a\u8fc7\u5bf9\u4efb\u610f\u4e00\u6761\u4ece\u6839\u5230\u53f6\u5b50\u7ed3\u70b9\u7684\u8def\u5f84\u4e0a\u5404\u4e2a\u7ed3\u70b9\u7740\u8272\u65b9\u5f0f\u7684\u9650\u5236&#xff0c;\u7ea2\u9ed1\u6811\u786e\u4fdd\u6ca1\u6709\u4e00\u6761\u8def\u5f84\u4f1a\u6bd4\u5176\u4ed6\u8def\u5f84\u957f\u51fa2\u500d&#xff0c;\u56e0\u800c\u662f\u63a5\u8fd1\u5e73\u8861\u7684\u3002\u5982\u4e0b\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"382\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072422-689849260acee.png\" width=\"742\" \/><\/p>\n<p>\u7ea2\u9ed1\u6811\u7684\u6027\u8d28&#xff1a;<\/p>\n<p>1\u3001\u6bcf\u4e2a\u7ed3\u70b9\u4e0d\u662f\u7ea2\u8272\u5c31\u662f\u9ed1\u8272\u3002<\/p>\n<p>2\u3001\u6839\u8282\u70b9\u662f\u9ed1\u8272\u7684 \u3002<\/p>\n<p>3\u3001\u5982\u679c\u4e00\u4e2a\u8282\u70b9\u662f\u7ea2\u8272\u7684&#xff0c;\u5219\u5b83\u7684\u4e24\u4e2a\u5b69\u5b50\u7ed3\u70b9\u662f\u9ed1\u8272\u7684\u3002&#xff08;\u4e5f\u5c31\u662f\u8bf4\u6811\u4e2d\u4e0d\u80fd\u51fa\u73b0\u8fde\u7eed\u7684\u7ea2\u8272\u7ed3\u70b9\u3002\u7236\u5b50\u7ed3\u70b9\u7684\u989c\u8272\u53ea\u80fd\u662f&#xff1a;\u9ed1&#043;\u9ed1\u3001\u9ed1&#043;\u7ea2\u3001\u7ea2&#043;\u9ed1\u4e09\u79cd\u60c5\u51b5&#xff09;\u3002<\/p>\n<p>4\u3001\u5bf9\u4e8e\u6bcf\u4e2a\u7ed3\u70b9&#xff0c;\u4ece\u8be5\u7ed3\u70b9\u5230\u5176\u6240\u6709\u53f6\u5b50\u7ed3\u70b9\u7684\u8def\u5f84\u4e0a&#xff0c;\u5747\u5305\u542b\u76f8\u540c\u6570\u76ee\u7684\u9ed1\u8272\u7ed3\u70b9 \u3002<\/p>\n<p>5\u3001\u6bcf\u4e2a\u53f6\u5b50\u7ed3\u70b9\u90fd\u662f\u9ed1\u8272\u7684(\u6b64\u5904\u7684\u53f6\u5b50\u7ed3\u70b9\u6307\u7684\u662f\u7a7a\u7ed3\u70b9&#xff09;\u3002<\/p>\n<p>\u4ece\u4e0a\u9762\u7ea2\u9ed1\u6811\u7684\u6027\u8d28\u6211\u4eec\u53ef\u4ee5\u77e5\u9053&#xff0c;\u4ece\u6839\u8282\u70b9\u5f00\u59cb&#xff0c;\u5982\u679c\u5b58\u5728\u6700\u957f\u8def\u5f84\u7684\u8bdd&#xff0c;\u7ea2\u9ed1\u6811\u4e2d\u7684\u6700\u957f\u8def\u5f84\u662f\u4e00\u9ed1\u4e00\u7ea2\u95f4\u9694\u7684\u8def\u5f84&#xff0c;\u5982\u679c\u5b58\u5728\u6700\u77ed\u8def\u5f84\u7684\u8bdd&#xff0c;\u6700\u77ed\u7684\u8def\u5f84\u662f\u5168\u9ed1\u7ed3\u70b9\u7684\u8def\u5f84\u3002<\/p>\n<p>\u4ece\u6839\u8282\u70b9\u5f00\u59cb&#xff0c;\u5047\u8bbe\u7ea2\u9ed1\u6811\u7684\u6bcf\u6761\u8def\u5f84\u90fd\u6709N\u4e2a\u9ed1\u8272\u7ed3\u70b9&#xff0c;\u5219\u6bcf\u6761\u8def\u5f84\u7684\u7ed3\u70b9\u6570\u91cf\u7684\u8303\u56f4\u4e3a[N&#xff0c;2N]\u3002<\/p>\n<h4 id=\"3.2%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E6%8F%92%E5%85%A5\">3.2\u3001\u7ea2\u9ed1\u6811\u7684\u63d2\u5165<\/h4>\n<p>\u7ea2\u9ed1\u6811\u662f\u5728\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u57fa\u7840\u4e0a\u52a0\u4e0a\u5176\u5e73\u8861\u9650\u5236\u6761\u4ef6&#xff0c;\u56e0\u6b64\u7ea2\u9ed1\u6811\u7684\u63d2\u5165\u53ef\u5206\u4e3a\u4e24\u6b65&#xff1a;<\/p>\n<p>1\u3001\u6309\u7167\u4e8c\u53c9\u641c\u7d22\u7684\u6811\u89c4\u5219\u63d2\u5165\u65b0\u8282\u70b9\u3002<\/p>\n<p>2\u3001\u68c0\u6d4b\u65b0\u8282\u70b9\u63d2\u5165\u540e&#xff0c;\u7ea2\u9ed1\u6811\u7684\u6027\u8d28\u662f\u5426\u9020\u5230\u7834\u574f\u3002<\/p>\n<p>\u56e0\u4e3a\u65b0\u8282\u70b9\u7684\u9ed8\u8ba4\u989c\u8272\u662f\u7ea2\u8272&#xff0c;\u56e0\u6b64\u5982\u679c\u5176\u53cc\u4eb2\u8282\u70b9\u7684\u989c\u8272\u662f\u9ed1\u8272&#xff0c;\u6ca1\u6709\u8fdd\u53cd\u7ea2\u9ed1\u6811\u4efb\u4f55\u6027\u8d28&#xff0c;\u5219\u4e0d\u9700\u8981\u8c03\u6574&#xff1b;\u4f46\u5f53\u65b0\u63d2\u5165\u8282\u70b9\u7684\u53cc\u4eb2\u8282\u70b9\u989c\u8272\u4e3a\u7ea2\u8272\u65f6&#xff0c;\u5c31\u8fdd\u53cd\u4e86\u6027\u8d28\u4e09\u4e0d\u80fd\u6709\u8fde\u5728\u4e00\u8d77\u7684\u7ea2\u8272\u8282\u70b9&#xff0c;\u6b64\u65f6\u9700\u8981\u5bf9\u7ea2\u9ed1\u6811\u5206\u60c5\u51b5\u6765\u8ba8\u8bba&#xff1a;\u7ea6\u5b9acur\u4e3a\u5f53\u524d\u8282\u70b9&#xff0c;p\u4e3a\u7236\u8282\u70b9&#xff0c;g\u4e3a\u7956\u7236\u8282\u70b9&#xff0c;u\u4e3a\u53d4\u53d4\u8282\u70b9\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u4e4b\u6240\u4ee5\u65b0\u7ed3\u70b9\u7684\u9ed8\u8ba4\u989c\u8272\u7ed9\u7ea2\u8272&#xff0c;\u539f\u56e0\u662f\u7834\u574f\u7ea2\u9ed1\u6811\u7684\u7b2c\u4e09\u6761\u6027\u8d28\u6bd4\u7834\u574f\u7ea2\u9ed1\u6811\u7684\u7b2c\u56db\u6761\u6240\u4ed8\u51fa\u7684\u4ee3\u4ef7\u5c0f\u3002<\/p>\n<h5 id=\"3.2.1%E3%80%81%E6%83%85%E5%86%B5%E4%B8%80\">3.2.1\u3001\u60c5\u51b5\u4e00<\/h5>\n<p>\u60c5\u51b5\u4e00&#xff1a;cur\u4e3a\u7ea2&#xff0c;p\u4e3a\u7ea2&#xff0c;g\u4e3a\u9ed1&#xff0c;u\u5b58\u5728\u4e14\u4e3a\u7ea2&#xff0c;\u4f8b\u5982<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"262\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072422-689849264109e.png\" width=\"607\" \/><\/p>\n<p>\u5176\u4e2da\u3001b\u3001c\u3001d\u3001e\u5206\u522b\u662f\u7ea2\u9ed1\u6811\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u5f0f&#xff1a;\u5c06p\u548cu\u6539\u4e3a\u9ed1&#xff0c;g\u6539\u4e3a\u7ea2&#xff0c;\u7136\u540e\u628ag\u5f53\u6210cur&#xff0c;\u7ee7\u7eed\u5411\u4e0a\u8c03\u6574\u3002<\/p>\n<h5 id=\"3.2.2%E3%80%81%E6%83%85%E5%86%B5%E4%BA%8C\">3.2.2\u3001\u60c5\u51b5\u4e8c<\/h5>\n<p>\u60c5\u51b5\u4e8c&#xff1a;cur\u4e3a\u7ea2&#xff0c;p\u4e3a\u7ea2&#xff0c;g\u4e3a\u9ed1&#xff0c;u\u4e0d\u5b58\u5728\u6216\u8005u\u5b58\u5728\u4e14\u4e3a\u9ed1&#xff0c;\u4f8b\u5982<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"298\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072422-6898492657223.png\" width=\"734\" \/><\/p>\n<p>\u5176\u4e2da\u3001b\u3001c\u3001d\u3001e\u5206\u522b\u662f\u7ea2\u9ed1\u6811\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u5f0f&#xff1a;<\/p>\n<p>1\u3001\u82e5p\u4e3ag\u7684\u5de6\u5b69\u5b50&#xff0c;cur\u4e3ap\u7684\u5de6\u5b69\u5b50&#xff0c;\u5219\u9488\u5bf9p\u8fdb\u884c\u53f3\u65cb\u8f6c&#xff0c;\u7136\u540ep\u53d8\u9ed1&#xff0c;g\u53d8\u7ea2\u3002<\/p>\n<p>2\u3001\u82e5p\u4e3ag\u7684\u53f3\u5b69\u5b50&#xff0c;cur\u4e3ap\u7684\u53f3\u5b69\u5b50&#xff0c;\u5219\u9488\u5bf9p\u8fdb\u884c\u5de6\u65cb\u8f6c&#xff0c;\u7136\u540ep\u53d8\u9ed1&#xff0c;g\u53d8\u7ea2\u3002<\/p>\n<h5 id=\"3.2.3%E3%80%81%E6%83%85%E5%86%B5%E4%B8%89\">3.2.3\u3001\u60c5\u51b5\u4e09<\/h5>\n<p>\u60c5\u51b5\u4e09&#xff1a;cur\u4e3a\u7ea2&#xff0c;p\u4e3a\u7ea2&#xff0c;g\u4e3a\u9ed1&#xff0c;u\u4e0d\u5b58\u5728\u6216\u8005u\u5b58\u5728\u4e14\u4e3a\u9ed1&#xff0c;\u4f8b\u5982<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"222\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072422-68984926664d9.png\" width=\"500\" \/><\/p>\n<p>\u5176\u4e2da\u3001b\u3001c\u3001d\u3001e\u5206\u522b\u662f\u7ea2\u9ed1\u6811\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u5f0f&#xff1a;<\/p>\n<p>1\u3001\u82e5p\u4e3ag\u7684\u5de6\u5b69\u5b50&#xff0c;cur\u4e3ap\u7684\u53f3\u5b69\u5b50&#xff0c;\u5219\u9488\u5bf9p\u505a\u5de6\u65cb\u8f6c&#xff0c;\u8f6c\u6362\u4e3a\u4e86\u60c5\u51b5\u4e8c\u3002<\/p>\n<p>2\u3001\u82e5p\u4e3ag\u7684\u53f3\u5b69\u5b50&#xff0c;cur\u4e3ap\u7684\u5de6\u5b69\u5b50&#xff0c;\u5219\u9488\u5bf9p\u505a\u53f3\u65cb\u8f6c&#xff0c;\u8f6c\u6362\u6210\u4e86\u60c5\u51b5\u4e8c\u3002<\/p>\n<h4 id=\"3.3%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E5%88%A0%E9%99%A4\">3.3\u3001\u7ea2\u9ed1\u6811\u7684\u5220\u9664<\/h4>\n<p>\u7ea2\u9ed1\u6811\u7684\u5220\u9664\u6bd4\u63d2\u5165\u8fd8\u8981\u590d\u6742&#xff0c;\u6709\u5174\u8da3\u53ef\u53c2\u8003&#xff1a;\u300a\u7b97\u6cd5\u5bfc\u8bba\u300b\u6216\u8005\u300aSTL\u6e90\u7801\u5256\u6790\u300b\u3002<\/p>\n<h4 id=\"3.4%E3%80%81%E7%BA%A2%E9%BB%91%E6%A0%91%E7%9A%84%E6%80%A7%E8%83%BD\">3.4\u3001\u7ea2\u9ed1\u6811\u7684\u6027\u80fd<\/h4>\n<p>\u7ea2\u9ed1\u6811\u548cAVL\u6811\u90fd\u662f\u9ad8\u6548\u7684\u5e73\u8861\u4e8c\u53c9\u6811&#xff0c;\u589e\u5220\u6539\u67e5\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u90fd\u662fO(log(N))&#xff0c;\u7ea2\u9ed1\u6811\u4e0d\u8ffd\u6c42\u7edd\u5bf9\u5e73\u8861&#xff0c;\u5176\u53ea\u9700\u4fdd\u8bc1\u6700\u957f\u8def\u5f84\u4e0d\u8d85\u8fc7\u6700\u77ed\u8def\u5f84\u76842\u500d&#xff0c;\u6240\u4ee5\u7ea2\u9ed1\u6811\u7684\u6027\u80fd\u5f80\u5f80\u6bd4AVL\u6811\u66f4\u4f18&#xff0c;\u800c\u4e14\u7ea2\u9ed1\u6811\u5b9e\u73b0\u6bd4\u8f83\u7b80\u5355&#xff0c;\u6240\u4ee5\u5b9e\u9645\u8fd0\u7528\u4e2d\u7ea2\u9ed1\u6811\u66f4\u591a\u3002<\/p>\n<p>\u7ea2\u9ed1\u6811\u7684\u5e94\u7528&#xff1a;<\/p>\n<p>1\u3001C&#043;&#043; STL\u5e93\u4e2d\u7684map\u548cset\u4ee5\u53camutil_map\u548cmutil_set\u3002<\/p>\n<p>2\u3001Java\u5e93\u3002<\/p>\n<p>3\u3001linux\u5185\u6838\u3002<\/p>\n<p>4\u3001\u5176\u4ed6\u4e00\u4e9b\u5e93\u3002<\/p>\n<h4 id=\"3.5%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0\">3.5\u3001\u6a21\u62df\u5b9e\u73b0<\/h4>\n<p>enum Colour<br \/>\n{<br \/>\nRED,<br \/>\nBLACK<br \/>\n};<\/p>\n<p>template&lt;class K, class V&gt;<br \/>\nstruct RBTreeNode<br \/>\n{<br \/>\nRBTreeNode&lt;K, V&gt;* _left;<br \/>\nRBTreeNode&lt;K, V&gt;* _right;<br \/>\nRBTreeNode&lt;K, V&gt;* _parent;<br \/>\npair&lt;K, V&gt; _kv;<\/p>\n<p>Colour _col;<\/p>\n<p>RBTreeNode(const pair&lt;K, V&gt;&amp; kv)<br \/>\n:_left(nullptr)<br \/>\n,_right(nullptr)<br \/>\n,_parent(nullptr)<br \/>\n,_kv(kv)<br \/>\n,_col(RED)<br \/>\n{}<br \/>\n};<\/p>\n<p>template&lt;class K, class V&gt;<br \/>\nclass RBTree<br \/>\n{<br \/>\ntypedef RBTreeNode&lt;K, V&gt; Node;<br \/>\npublic:<br \/>\nbool Insert(const pair&lt;K, V&gt;&amp; kv)<br \/>\n{<br \/>\nif (_root &#061;&#061; nullptr)<br \/>\n{<br \/>\n_root &#061; new Node(kv);<br \/>\n_root-&gt;_col &#061; BLACK;<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>Node* parent &#061; nullptr;<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur)<br \/>\n{<br \/>\nif (cur-&gt;_kv.first &lt; kv.first)<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_right;<br \/>\n}<br \/>\nelse if (cur-&gt;_kv.first &gt; kv.first)<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn false;<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ \u65b0\u589e\u7ed3\u70b9<br \/>\ncur &#061; new Node(kv);<br \/>\nif (parent-&gt;_kv.first &lt; kv.first)<br \/>\n{<br \/>\nparent-&gt;_right &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparent-&gt;_left &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<\/p>\n<p>\/\/ \u8c03\u6574<br \/>\nwhile (parent &amp;&amp; parent-&gt;_col &#061;&#061; RED)<br \/>\n{<br \/>\nNode* grandfather &#061; parent-&gt;_parent;<br \/>\nif (parent &#061;&#061; grandfather-&gt;_left) \/\/ p\u5728g\u7684\u5de6\u8fb9<br \/>\n{<br \/>\nNode* uncle &#061; grandfather-&gt;_right;<br \/>\nif (uncle &amp;&amp; uncle-&gt;_col &#061;&#061; RED) \/\/ u\u5b58\u5728\u4e14\u4e3a\u7ea2<br \/>\n{<br \/>\n\/\/ \u53d8\u8272<br \/>\nparent-&gt;_col &#061; uncle-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<\/p>\n<p>\/\/\u7ee7\u7eed\u5411\u4e0a\u5904\u7406<br \/>\ncur &#061; grandfather;<br \/>\nparent &#061; cur-&gt;_parent;<br \/>\n}<br \/>\nelse \/\/ u\u4e0d\u5b58\u5728&#xff0c;\u6216\u8005u\u5b58\u5728\u4e14\u4e3a\u9ed1<br \/>\n{<br \/>\nif (cur &#061;&#061; parent-&gt;_left) \/\/ cur\u5728p\u7684\u5de6\u8fb9<br \/>\n{<br \/>\nRotateR(grandfather);<br \/>\nparent-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nelse \/\/ cur\u5728p\u7684\u53f3\u8fb9<br \/>\n{<br \/>\nRotateL(parent);<br \/>\nRotateR(grandfather);<br \/>\ncur-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nbreak;<br \/>\n}<br \/>\n}<br \/>\nelse \/\/ p\u5728g\u7684\u53f3\u8fb9<br \/>\n{<br \/>\nNode* uncle &#061; grandfather-&gt;_left;<br \/>\nif (uncle &amp;&amp; uncle-&gt;_col &#061;&#061; RED) \/\/ u\u5b58\u5728\u4e14\u4e3a\u7ea2<br \/>\n{<br \/>\nparent-&gt;_col &#061; uncle-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<\/p>\n<p>cur &#061; grandfather;<br \/>\nparent &#061; cur-&gt;_parent;<br \/>\n}<br \/>\nelse \/\/ u\u4e0d\u5b58\u5728&#xff0c;\u6216\u8005u\u5b58\u5728\u4e14\u4e3a\u9ed1<br \/>\n{<br \/>\nif (cur &#061;&#061; parent-&gt;_right) \/\/ cur\u5728p\u7684\u53f3\u8fb9<br \/>\n{<br \/>\nRotateL(grandfather);<br \/>\nparent-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nelse \/\/ cur\u5728p\u7684\u5de6\u8fb9<br \/>\n{<br \/>\nRotateR(parent);<br \/>\nRotateL(grandfather);<br \/>\ncur-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nbreak;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n_root-&gt;_col &#061; BLACK;<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>void RotateL(Node* parent) \/\/ \u5de6\u65cb<br \/>\n{<br \/>\nNode* subR &#061; parent-&gt;_right;<br \/>\nNode* subRL &#061; subR-&gt;_left;<\/p>\n<p>parent-&gt;_right &#061; subRL;<br \/>\nsubR-&gt;_left &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>parent-&gt;_parent &#061; subR;<br \/>\nif (subRL)<br \/>\nsubRL-&gt;_parent &#061; parent;<\/p>\n<p>if (_root &#061;&#061; parent)<br \/>\n{<br \/>\n_root &#061; subR;<br \/>\nsubR-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent)<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subR;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subR;<br \/>\n}<br \/>\nsubR-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\n}<\/p>\n<p>void RotateR(Node* parent) \/\/\u53f3\u65cb<br \/>\n{<br \/>\nNode* subL &#061; parent-&gt;_left;<br \/>\nNode* subLR &#061; subL-&gt;_right;<\/p>\n<p>parent-&gt;_left &#061; subLR;<br \/>\nif (subLR)<br \/>\nsubLR-&gt;_parent &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>subL-&gt;_right &#061; parent;<br \/>\nparent-&gt;_parent &#061; subL;<\/p>\n<p>if (_root &#061;&#061; parent)<br \/>\n{<br \/>\n_root &#061; subL;<br \/>\nsubL-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent)<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subL;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subL;<br \/>\n}<br \/>\nsubL-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\n}<\/p>\n<p>void InOrder()<br \/>\n{<br \/>\n_InOrder(_root);<br \/>\ncout &lt;&lt; endl;<br \/>\n}<\/p>\n<p>bool IsBalance()<br \/>\n{<br \/>\nif (_root &#061;&#061; nullptr)<br \/>\nreturn true;<\/p>\n<p>if (_root-&gt;_col &#061;&#061; RED)<br \/>\nreturn false;<\/p>\n<p>int refVal &#061; 0; \/\/ \u53c2\u8003\u503c<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur)<br \/>\n{<br \/>\nif (cur-&gt;_col &#061;&#061; BLACK)<br \/>\n{<br \/>\n&#043;&#043;refVal;<br \/>\n}<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<\/p>\n<p>int blacknum &#061; 0;<br \/>\nreturn Check(_root, blacknum, refVal);<br \/>\n}<\/p>\n<p>int Height()<br \/>\n{<br \/>\nreturn _Height(_root);<br \/>\n}<\/p>\n<p>size_t Size()<br \/>\n{<br \/>\nreturn _Size(_root);<br \/>\n}<\/p>\n<p>Node* Find(const K&amp; key)<br \/>\n{<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur)<br \/>\n{<br \/>\nif (cur-&gt;_kv.first &lt; key)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_right;<br \/>\n}<br \/>\nelse if (cur-&gt;_kv.first &gt; key)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn cur;<br \/>\n}<br \/>\n}<br \/>\nreturn NULL;<br \/>\n}<\/p>\n<p>private:<br \/>\nvoid _InOrder(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn;<\/p>\n<p>_InOrder(root-&gt;_left);<br \/>\ncout &lt;&lt; root-&gt;_kv.first &lt;&lt; &#039;:&#039; &lt;&lt; root-&gt;_kv.second &lt;&lt; endl;<br \/>\n_InOrder(root-&gt;_right);<br \/>\n}<\/p>\n<p>bool Check(Node* root, int blacknum, const int refVal)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\n{<br \/>\nif (blacknum !&#061; refVal)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;\u5b58\u5728\u9ed1\u8272\u7ed3\u70b9\u6570\u91cf\u4e0d\u76f8\u7b49\u7684\u8def\u5f84&#034; &lt;&lt; endl;<br \/>\nreturn false;<br \/>\n}<br \/>\nreturn true;<br \/>\n}<\/p>\n<p>if (root-&gt;_col &#061;&#061; RED &amp;&amp; root-&gt;_parent-&gt;_col &#061;&#061; RED)<br \/>\n{<br \/>\ncout &lt;&lt; &#034;\u6709\u8fde\u7eed\u7684\u7ea2\u8272\u7ed3\u70b9&#034; &lt;&lt; endl;<br \/>\nreturn false;<br \/>\n}<\/p>\n<p>if (root-&gt;_col &#061;&#061; BLACK)<br \/>\n{<br \/>\n&#043;&#043;blacknum;<br \/>\n}<\/p>\n<p>return Check(root-&gt;_left, blacknum, refVal)<br \/>\n&amp;&amp; Check(root-&gt;_right, blacknum, refVal);<br \/>\n}<\/p>\n<p>int _Height(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\n{<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>int leftHeight &#061; _Height(root-&gt;_left);<br \/>\nint rightHeight &#061; _Height(root-&gt;_right);<\/p>\n<p>return leftHeight &gt; rightHeight ? leftHeight &#043; 1 : rightHeight &#043; 1;<br \/>\n}<\/p>\n<p>size_t _Size(Node* root)<br \/>\n{<br \/>\nif (root &#061;&#061; nullptr)<br \/>\nreturn 0;<\/p>\n<p>return _Size(root-&gt;_left) &#043; _Size(root-&gt;_right) &#043; 1;<br \/>\n}<\/p>\n<p>private:<br \/>\nNode* _root &#061; nullptr;<br \/>\n}; <\/p>\n<h3 id=\"4%E3%80%81%E6%A8%A1%E6%8B%9F%E5%AE%9E%E7%8E%B0map%E5%92%8Cset\">4\u3001\u6a21\u62df\u5b9e\u73b0map\u548cset<\/h3>\n<p>set\u548cmap\u7684\u5e95\u5c42\u90fd\u662f\u7ea2\u9ed1\u6811&#xff0c;\u56e0\u6b64\u53ea\u9700\u5728set\u548cmap\u5185\u90e8\u5c01\u88c5\u4e00\u68f5\u7ea2\u9ed1\u6811&#xff0c;\u7136\u540e\u5c06\u5176\u63a5\u53e3\u5305\u88c5\u4e0b\u5373\u53ef\u3002<\/p>\n<p>RBTree.h&#xff1a;<\/p>\n<p>enum Colour<br \/>\n{<br \/>\nRED,<br \/>\nBLACK<br \/>\n};<\/p>\n<p>template&lt;class T&gt;<br \/>\nstruct RBTreeNode<br \/>\n{<br \/>\nRBTreeNode&lt;T&gt;* _left;<br \/>\nRBTreeNode&lt;T&gt;* _right;<br \/>\nRBTreeNode&lt;T&gt;* _parent;<br \/>\nT _data;<\/p>\n<p>Colour _col;<\/p>\n<p>RBTreeNode(const T&amp; data)<br \/>\n:_left(nullptr)<br \/>\n, _right(nullptr)<br \/>\n, _parent(nullptr)<br \/>\n, _data(data)<br \/>\n, _col(RED)<br \/>\n{}<br \/>\n};<\/p>\n<p>template&lt;class T, class Ref, class Ptr&gt;<br \/>\nstruct __TreeIterator<br \/>\n{<br \/>\ntypedef RBTreeNode&lt;T&gt; Node;<br \/>\ntypedef __TreeIterator&lt;T, Ref, Ptr&gt; Self;<br \/>\nNode* _node;<\/p>\n<p>__TreeIterator(Node* node)<br \/>\n:_node(node)<br \/>\n{}<\/p>\n<p>Ref operator*()<br \/>\n{<br \/>\nreturn _node-&gt;_data;<br \/>\n}<\/p>\n<p>Ptr operator-&gt;()<br \/>\n{<br \/>\nreturn &amp;_node-&gt;_data;<br \/>\n}<\/p>\n<p>Self&amp; operator&#8211;()<br \/>\n{<br \/>\n\/\/ \u81ea\u5df1\u5b9e\u73b0<br \/>\n}<\/p>\n<p>Self&amp; operator&#043;&#043;()<br \/>\n{<br \/>\nif (_node-&gt;_right) \/\/ \u53f3\u4e0d\u4e3a\u7a7a<br \/>\n{<br \/>\nNode* cur &#061; _node-&gt;_right;<br \/>\nwhile (cur-&gt;_left)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\n_node &#061; cur;<br \/>\n}<br \/>\nelse \/\/ \u53f3\u4e3a\u7a7a<br \/>\n{<br \/>\nNode* cur &#061; _node;<br \/>\nNode* parent &#061; cur-&gt;_parent;<br \/>\nwhile (parent &amp;&amp; cur &#061;&#061; parent-&gt;_right)<br \/>\n{<br \/>\ncur &#061; parent;<br \/>\nparent &#061; parent-&gt;_parent;<br \/>\n}<br \/>\n_node &#061; parent;<br \/>\n}<br \/>\nreturn *this;<br \/>\n}<\/p>\n<p>bool operator!&#061;(const Self&amp; s)<br \/>\n{<br \/>\nreturn _node !&#061; s._node;<br \/>\n}<\/p>\n<p>bool operator&#061;&#061;(const Self&amp; s)<br \/>\n{<br \/>\nreturn _node &#061;&#061; s._node;<br \/>\n}<br \/>\n};<\/p>\n<p>\/\/set-&gt;RBTree&lt;K, K, SetKeyOfT&gt; _t;<br \/>\n\/\/map-&gt;RBTree&lt;K, pair&lt;const K, T&gt;, MapKeyOfT&gt; _t;<br \/>\ntemplate&lt;class K, class T, class KeyOfT&gt;<br \/>\nclass RBTree<br \/>\n{<br \/>\ntypedef RBTreeNode&lt;T&gt; Node;<br \/>\npublic:<br \/>\ntypedef __TreeIterator&lt;T, T&amp;, T*&gt; iterator;<br \/>\ntypedef __TreeIterator&lt;T, const T&amp;, const T*&gt; const_iterator;<\/p>\n<p>iterator begin()<br \/>\n{<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur &amp;&amp; cur-&gt;_left)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<\/p>\n<p>return iterator(cur);<br \/>\n}<\/p>\n<p>iterator end()<br \/>\n{<br \/>\nreturn iterator(nullptr);<br \/>\n}<\/p>\n<p>const_iterator begin() const<br \/>\n{<br \/>\nNode* cur &#061; _root;<br \/>\nwhile (cur &amp;&amp; cur-&gt;_left)<br \/>\n{<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<\/p>\n<p>return const_iterator(cur);<br \/>\n}<\/p>\n<p>const_iterator end() const<br \/>\n{<br \/>\nreturn const_iterator(nullptr);<br \/>\n}<\/p>\n<p>\/\/pair&lt;iterator, bool&gt; Insert(const T&amp; data)<br \/>\npair&lt;Node*, bool&gt; Insert(const T&amp; data) \/\/ \u5982\u679c\u7528\u4e0a\u9762\u7684\u4f1a\u6709\u8fed\u4ee3\u5668\u7c7b\u578b\u8f6c\u6362\u7684\u95ee\u9898\u3002<br \/>\n{<br \/>\nif (_root &#061;&#061; nullptr)<br \/>\n{<br \/>\n_root &#061; new Node(data);<br \/>\n_root-&gt;_col &#061; BLACK;<br \/>\nreturn make_pair(_root, true);<br \/>\n}<\/p>\n<p>Node* parent &#061; nullptr;<br \/>\nNode* cur &#061; _root;<br \/>\nKeyOfT kot;<\/p>\n<p>while (cur)<br \/>\n{<br \/>\nif (kot(cur-&gt;_data) &lt; kot(data))<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_right;<br \/>\n}<br \/>\nelse if (kot(cur-&gt;_data) &gt; kot(data))<br \/>\n{<br \/>\nparent &#061; cur;<br \/>\ncur &#061; cur-&gt;_left;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nreturn make_pair(cur, false);<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ \u65b0\u589e\u7ed3\u70b9 \/\/<br \/>\ncur &#061; new Node(data);<br \/>\nNode* newnode &#061; cur;<br \/>\nif (kot(parent-&gt;_data) &lt; kot(data))<br \/>\n{<br \/>\nparent-&gt;_right &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparent-&gt;_left &#061; cur;<br \/>\ncur-&gt;_parent &#061; parent;<br \/>\n}<\/p>\n<p>\/\/<br \/>\nwhile (parent &amp;&amp; parent-&gt;_col &#061;&#061; RED)<br \/>\n{<br \/>\nNode* grandfather &#061; parent-&gt;_parent;<br \/>\nif (parent &#061;&#061; grandfather-&gt;_left)<br \/>\n{<br \/>\nNode* uncle &#061; grandfather-&gt;_right;<br \/>\nif (uncle &amp;&amp; uncle-&gt;_col &#061;&#061; RED)<br \/>\n{<br \/>\n\/\/ \u53d8\u8272<br \/>\nparent-&gt;_col &#061; uncle-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<\/p>\n<p>\/\/\u7ee7\u7eed\u5411\u4e0a\u5904\u7406<br \/>\ncur &#061; grandfather;<br \/>\nparent &#061; cur-&gt;_parent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (cur &#061;&#061; parent-&gt;_left)<br \/>\n{<br \/>\nRotateR(grandfather);<br \/>\nparent-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nRotateL(parent);<br \/>\nRotateR(grandfather);<br \/>\ncur-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nbreak;<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nNode* uncle &#061; grandfather-&gt;_left;<br \/>\nif (uncle &amp;&amp; uncle-&gt;_col &#061;&#061; RED)<br \/>\n{<br \/>\nparent-&gt;_col &#061; uncle-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<\/p>\n<p>cur &#061; grandfather;<br \/>\nparent &#061; cur-&gt;_parent;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (cur &#061;&#061; parent-&gt;_right)<br \/>\n{<br \/>\nRotateL(grandfather);<br \/>\nparent-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nRotateR(parent);<br \/>\nRotateL(grandfather);<br \/>\ncur-&gt;_col &#061; BLACK;<br \/>\ngrandfather-&gt;_col &#061; RED;<br \/>\n}<br \/>\nbreak;<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n_root-&gt;_col &#061; BLACK;<br \/>\nreturn make_pair(newnode, true);<br \/>\n}<\/p>\n<p>void RotateL(Node* parent) \/\/ \u5de6\u65cb<br \/>\n{<br \/>\nNode* subR &#061; parent-&gt;_right;<br \/>\nNode* subRL &#061; subR-&gt;_left;<\/p>\n<p>parent-&gt;_right &#061; subRL;<br \/>\nsubR-&gt;_left &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>parent-&gt;_parent &#061; subR;<br \/>\nif (subRL)<br \/>\nsubRL-&gt;_parent &#061; parent;<\/p>\n<p>if (_root &#061;&#061; parent)<br \/>\n{<br \/>\n_root &#061; subR;<br \/>\nsubR-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent)<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subR;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subR;<br \/>\n}<br \/>\nsubR-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\n}<\/p>\n<p>void RotateR(Node* parent) \/\/\u53f3\u65cb<br \/>\n{<br \/>\nNode* subL &#061; parent-&gt;_left;<br \/>\nNode* subLR &#061; subL-&gt;_right;<\/p>\n<p>parent-&gt;_left &#061; subLR;<br \/>\nif (subLR)<br \/>\nsubLR-&gt;_parent &#061; parent;<\/p>\n<p>Node* parentParent &#061; parent-&gt;_parent;<\/p>\n<p>subL-&gt;_right &#061; parent;<br \/>\nparent-&gt;_parent &#061; subL;<\/p>\n<p>if (_root &#061;&#061; parent)<br \/>\n{<br \/>\n_root &#061; subL;<br \/>\nsubL-&gt;_parent &#061; nullptr;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (parentParent-&gt;_left &#061;&#061; parent)<br \/>\n{<br \/>\nparentParent-&gt;_left &#061; subL;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nparentParent-&gt;_right &#061; subL;<br \/>\n}<br \/>\nsubL-&gt;_parent &#061; parentParent;<br \/>\n}<br \/>\n}<br \/>\nprivate:<\/p>\n<p>Node* _root &#061; nullptr;<br \/>\n}; <\/p>\n<p>MyMap.h&#xff1a;<\/p>\n<p>#include &#034;RBTree.h&#034;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\ntemplate&lt;class K, class V&gt;<br \/>\nclass map<br \/>\n{<br \/>\npublic:<br \/>\nstruct MapKeyOfT<br \/>\n{<br \/>\nconst K&amp; operator()(const pair&lt;K, V&gt;&amp; kv)<br \/>\n{<br \/>\nreturn kv.first;<br \/>\n}<br \/>\n};<\/p>\n<p>typedef typename RBTree&lt;K, pair&lt;const K, V&gt;, MapKeyOfT&gt;::iterator iterator;\/\/\u4ec5key\u4e0d\u53ef\u6539<br \/>\ntypedef typename RBTree&lt;K, pair&lt;const K, V&gt;, MapKeyOfT&gt;::const_iterator const_iterator; \/\/ key\u4ee5\u53cavalue\u90fd\u4e0d\u53ef\u6539<\/p>\n<p>iterator begin()<br \/>\n{<br \/>\nreturn _t.begin();<br \/>\n}<\/p>\n<p>iterator end()<br \/>\n{<br \/>\nreturn _t.end();<br \/>\n}<\/p>\n<p>V&amp; operator[](const K&amp; key)<br \/>\n{<br \/>\npair&lt;iterator, bool&gt; ret &#061; insert(make_pair(key, V()));<br \/>\nreturn ret.first-&gt;second;<br \/>\n}<\/p>\n<p>pair&lt;iterator, bool&gt; insert(const pair&lt;K, V&gt;&amp; kv)<br \/>\n{<br \/>\nreturn _t.Insert(kv);<br \/>\n}<\/p>\n<p>private:<br \/>\nRBTree&lt;K, pair&lt;const K, V&gt;, MapKeyOfT&gt; _t;<br \/>\n};<br \/>\n}<\/p>\n<p>MySet.h&#xff1a;<\/p>\n<p>#include &#034;RBTree.h&#034;<\/p>\n<p>namespace bit<br \/>\n{<br \/>\ntemplate&lt;class K&gt;<br \/>\nclass set<br \/>\n{<br \/>\npublic:<br \/>\nstruct SetKeyOfT<br \/>\n{<br \/>\nconst K&amp; operator()(const K&amp; key)<br \/>\n{<br \/>\nreturn key;<br \/>\n}<br \/>\n};<\/p>\n<p>\/\/ \u5bf9\u7c7b\u6a21\u677f\u53d6\u5185\u5d4c\u7c7b\u578b&#xff0c;\u52a0typename\u544a\u8bc9\u7f16\u8bd1\u5668\u8fd9\u91cc\u662f\u7c7b\u578b<br \/>\ntypedef typename RBTree&lt;K, K, SetKeyOfT&gt;::const_iterator iterator;<br \/>\ntypedef typename RBTree&lt;K, K, SetKeyOfT&gt;::const_iterator const_iterator;<\/p>\n<p>iterator begin() const<br \/>\n{<br \/>\nreturn _t.begin();<br \/>\n}<\/p>\n<p>iterator end() const<br \/>\n{<br \/>\nreturn _t.end();<br \/>\n}<\/p>\n<p>pair&lt;iterator, bool&gt; insert(const K&amp; key)<br \/>\n{<br \/>\nreturn _t.Insert(key);<br \/>\n}<\/p>\n<p>private:<br \/>\nRBTree&lt;K, K, SetKeyOfT&gt; _t;<br \/>\n};<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb37\u6b21\u3002\u4e3b\u8981\u8bb2\u89e3\u5173\u4e8eAVL\u6811\u3001\u7ea2\u9ed1\u6811\u3001\u4ee5\u53ca\u5c01\u88c5\u51fa\u7684map\u548cset<\/p>\n","protected":false},"author":2,"featured_media":50964,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,190],"topic":[],"class_list":["post-50973","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\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\/50973.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb37\u6b21\u3002\u4e3b\u8981\u8bb2\u89e3\u5173\u4e8eAVL\u6811\u3001\u7ea2\u9ed1\u6811\u3001\u4ee5\u53ca\u5c01\u88c5\u51fa\u7684map\u548cset\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/50973.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T07:24:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-689849258e514.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=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50973.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/50973.html\",\"name\":\"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T07:24:23+00:00\",\"dateModified\":\"2025-08-10T07:24:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/50973.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/50973.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/50973.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\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":"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\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\/50973.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb37\u6b21\u3002\u4e3b\u8981\u8bb2\u89e3\u5173\u4e8eAVL\u6811\u3001\u7ea2\u9ed1\u6811\u3001\u4ee5\u53ca\u5c01\u88c5\u51fa\u7684map\u548cset","og_url":"https:\/\/www.wsisp.com\/helps\/50973.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T07:24:23+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810072421-689849258e514.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/50973.html","url":"https:\/\/www.wsisp.com\/helps\/50973.html","name":"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\u6811 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T07:24:23+00:00","dateModified":"2025-08-10T07:24:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/50973.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/50973.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/50973.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c\u5341\u516d\u8bb2\uff1aAVL\u6811\u548c\u7ea2\u9ed1\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\/50973","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=50973"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/50973\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/50964"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=50973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=50973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=50973"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=50973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}