{"id":57770,"date":"2025-08-15T19:40:02","date_gmt":"2025-08-15T11:40:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57770.html"},"modified":"2025-08-15T19:40:02","modified_gmt":"2025-08-15T11:40:02","slug":"%e4%ba%8c%e5%8f%89%e6%90%9c%e7%b4%a2%e6%a0%91%e7%9a%84%e6%a6%82%e5%bf%b5%e5%92%8c%e8%af%a6%e7%bb%86%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57770.html","title":{"rendered":"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd"},"content":{"rendered":"<p>\u4e8c\u53c9\u641c\u7d22\u6811&#xff08;Binary Search Tree&#xff0c;BST&#xff09;&#xff0c;\u53c8\u79f0\u4e8c\u53c9\u6392\u5e8f\u6811\u6216\u4e8c\u53c9\u67e5\u627e\u6811&#xff0c;\u662f\u4e00\u79cd\u57fa\u4e8e\u4e8c\u53c9\u6811\u7684\u9ad8\u6548\u6570\u636e\u7ed3\u6784&#xff0c;\u5176\u6838\u5fc3\u7279\u6027\u662f\u901a\u8fc7\u8282\u70b9\u503c\u7684\u504f\u5e8f\u5173\u7cfb\u5b9e\u73b0\u5feb\u901f\u67e5\u627e\u3001\u63d2\u5165\u548c\u5220\u9664\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u5176\u7cfb\u7edf\u6027\u4ecb\u7ecd&#xff1a;<\/p>\n<hr \/>\n<h4>&#x1f333; \u200b\u4e00\u3001\u57fa\u672c\u6982\u5ff5\u200b<\/h4>\n<li>\n<p>\u200b\u5b9a\u4e49\u200b<br \/>\n\u4e8c\u53c9\u641c\u7d22\u6811\u662f\u6ee1\u8db3\u4ee5\u4e0b\u6027\u8d28\u7684\u4e8c\u53c9\u6811&#xff1a;<\/p>\n<ul>\n<li>\u82e5\u5de6\u5b50\u6811\u975e\u7a7a&#xff0c;\u5219\u5de6\u5b50\u6811\u6240\u6709\u8282\u70b9\u7684\u503c\u5747\u5c0f\u4e8e\u6839\u8282\u70b9\u7684\u503c&#xff1b;<\/li>\n<li>\u82e5\u53f3\u5b50\u6811\u975e\u7a7a&#xff0c;\u5219\u53f3\u5b50\u6811\u6240\u6709\u8282\u70b9\u7684\u503c\u5747\u5927\u4e8e\u6839\u8282\u70b9\u7684\u503c&#xff1b;<\/li>\n<li>\u5de6\u53f3\u5b50\u6811\u4e5f\u5fc5\u987b\u662f\u4e8c\u53c9\u641c\u7d22\u6811\u3002<\/li>\n<li>\u7a7a\u6811\u662f\u5408\u6cd5\u7684\u4e8c\u53c9\u641c\u7d22\u6811\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u5173\u952e\u7279\u6027\u200b<\/p>\n<ul>\n<li>\u200b\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u200b&#xff1a;\u5bf9BST\u8fdb\u884c\u4e2d\u5e8f\u904d\u5386&#xff08;\u5de6\u2192\u6839\u2192\u53f3&#xff09;&#xff0c;\u7ed3\u679c\u662f\u4e00\u4e2a\u4e25\u683c\u9012\u589e\u5e8f\u5217\u3002<\/li>\n<li>\u200b\u65e0\u91cd\u590d\u952e\u503c\u200b&#xff1a;\u901a\u5e38\u8981\u6c42\u8282\u70b9\u952e\u503c\u552f\u4e00&#xff0c;\u907f\u514d\u5197\u4f59\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>\u2699\ufe0f \u200b\u4e8c\u3001\u6838\u5fc3\u64cd\u4f5c\u200b<\/h4>\n<h5>\u200b1. \u67e5\u627e&#xff08;Search&#xff09;\u200b\u200b<\/h5>\n<ul>\n<li>\u200b\u903b\u8f91\u200b&#xff1a;\u4ece\u6839\u8282\u70b9\u5f00\u59cb&#xff0c;\u4e0e\u76ee\u6807\u503c\u6bd4\u8f83&#xff1a;\n<ul>\n<li>\u76ee\u6807\u503c &lt; \u5f53\u524d\u8282\u70b9\u503c \u2192 \u9012\u5f52\u641c\u7d22\u5de6\u5b50\u6811&#xff1b;<\/li>\n<li>\u76ee\u6807\u503c &gt; \u5f53\u524d\u8282\u70b9\u503c \u2192 \u9012\u5f52\u641c\u7d22\u53f3\u5b50\u6811&#xff1b;<\/li>\n<li>\u76f8\u7b49\u5219\u8fd4\u56de\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200b\u65f6\u95f4\u590d\u6742\u5ea6\u200b&#xff1a;\n<ul>\n<li>\u5e73\u8861\u6811&#xff1a;\u200bO(log N)\u200b\u200b&#xff08;\u6811\u9ad8\u8fd1\u4f3c\u5bf9\u6570\u7ea7&#xff09;&#xff1b;<\/li>\n<li>\u9000\u5316\u4e3a\u94fe\u8868&#xff1a;\u200bO(N)\u200b\u200b&#xff08;\u6700\u574f\u60c5\u51b5&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u200b2. \u63d2\u5165&#xff08;Insertion&#xff09;\u200b\u200b<\/h5>\n<ul>\n<li>\u200b\u903b\u8f91\u200b&#xff1a;\n<ul>\n<li>\u6811\u4e3a\u7a7a \u2192 \u521b\u5efa\u65b0\u8282\u70b9\u4f5c\u4e3a\u6839\u8282\u70b9&#xff1b;<\/li>\n<li>\u6811\u975e\u7a7a \u2192 \u6309\u67e5\u627e\u903b\u8f91\u5b9a\u4f4d\u63d2\u5165\u4f4d\u7f6e&#xff0c;\u5c06\u65b0\u8282\u70b9\u6302\u8f7d\u5230\u53f6\u5b50\u8282\u70b9\u7684\u5de6\/\u53f3\u5b50\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200b\u793a\u4f8b\u200b&#xff1a;<br \/>\n\u5728\u6811[5, 3, 7]\u4e2d\u63d2\u51654&#xff1a;<\/p>\n<ul>\n<li>4 &lt; 5 \u2192 \u8fdb\u5165\u5de6\u5b50\u6811&#xff1b;<\/li>\n<li>4 &gt; 3 \u2192 \u4f5c\u4e3a3\u7684\u53f3\u5b50\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5>\u200b3. \u5220\u9664&#xff08;Deletion&#xff09;\u200b\u200b<\/h5>\n<p>\u5220\u9664\u9700\u5206\u4e09\u79cd\u60c5\u51b5\u5904\u7406&#xff1a;<\/p>\n<ul>\n<li>\u200b\u65e0\u5b50\u8282\u70b9\u200b&#xff1a;\u76f4\u63a5\u5220\u9664&#xff08;\u5982\u5220\u9664\u53f6\u5b50\u8282\u70b9&#xff09;\u3002<\/li>\n<li>\u200b\u4ec5\u4e00\u4e2a\u5b50\u8282\u70b9\u200b&#xff1a;\u7528\u5b50\u8282\u70b9\u66ff\u4ee3\u88ab\u5220\u8282\u70b9&#xff08;\u5982\u5220\u9664\u4ec5\u5de6\u5b50\u6811\u7684\u8282\u70b9&#xff09;\u3002<\/li>\n<li>\u200b\u6709\u4e24\u4e2a\u5b50\u8282\u70b9\u200b&#xff1a;\n<li>\u627e\u5230\u53f3\u5b50\u6811\u7684\u6700\u5c0f\u8282\u70b9\u200b&#xff08;\u6216\u5de6\u5b50\u6811\u7684\u6700\u5927\u8282\u70b9&#xff09;&#xff1b;<\/li>\n<li>\u7528\u8be5\u8282\u70b9\u7684\u503c\u8986\u76d6\u88ab\u5220\u8282\u70b9&#xff1b;<\/li>\n<li>\u9012\u5f52\u5220\u9664\u53f3\u5b50\u6811\u4e2d\u7684\u6700\u5c0f\u8282\u70b9\u3002<\/li>\n<\/li>\n<li>\u200b\u793a\u4f8b\u200b&#xff1a;<br \/>\n\u5220\u9664\u6839\u8282\u70b9\u65f6&#xff0c;\u7528\u53f3\u5b50\u6811\u6700\u5c0f\u8282\u70b9&#xff08;\u59826&#xff09;\u66ff\u6362\u6839\u503c&#xff0c;\u518d\u5220\u9664\u539f6\u8282\u70b9\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>&#x1f527; \u200b\u4e09\u3001\u5b9e\u73b0\u5173\u952e\u70b9\u200b<\/h4>\n<li>\n<p>\u200b\u5b58\u50a8\u7ed3\u6784\u200b<\/p>\n<ul>\n<li>\u8282\u70b9\u5305\u542b&#xff1a;\u952e\u503c&#xff08;key&#xff09;\u3001\u5de6\u5b50\u8282\u70b9\u6307\u9488\u3001\u53f3\u5b50\u8282\u70b9\u6307\u9488\u3002<\/li>\n<li>C\u8bed\u8a00\u793a\u4f8b&#xff1a;\n<p>typedef struct TreeNode {<br \/>\n    int data;<br \/>\n    struct TreeNode *left, *right;<br \/>\n} TreeNode;\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u9012\u5f52 vs \u8fed\u4ee3\u200b<\/p>\n<ul>\n<li>\u200b\u9012\u5f52\u5b9e\u73b0\u200b&#xff1a;\u4ee3\u7801\u7b80\u6d01&#xff0c;\u4f46\u6808\u7a7a\u95f4\u5f00\u9500\u5927&#xff08;\u5982insertR()&#xff09;\u3002<\/li>\n<li>\u200b\u8fed\u4ee3\u5b9e\u73b0\u200b&#xff1a;\u6548\u7387\u66f4\u9ad8&#xff0c;\u9700\u8bb0\u5f55\u7236\u8282\u70b9\u4ee5\u7ef4\u62a4\u94fe\u63a5&#xff08;\u5982Insert()\u4e2d\u7684parent\u6307\u9488&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u5e73\u8861\u6027\u7ef4\u62a4\u200b<\/p>\n<ul>\n<li>\u666e\u901aBST\u53ef\u80fd\u9000\u5316\u4e3a\u94fe\u8868&#xff08;\u5982\u63d2\u5165\u6709\u5e8f\u5e8f\u52171,2,3,&#8230;,N&#xff09;\u3002<\/li>\n<li>\u5b9e\u9645\u5de5\u7a0b\u4e2d\u9700\u5f15\u5165\u81ea\u5e73\u8861BST\u200b&#xff08;\u5982AVL\u6811\u3001\u7ea2\u9ed1\u6811&#xff09;\u4fdd\u8bc1O(log N)\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>\u23f1\ufe0f \u200b\u56db\u3001\u6027\u80fd\u5206\u6790\u200b<\/h4>\n<table>\n<tr>\u200b\u64cd\u4f5c\u200b\u200b\u5e73\u5747\u65f6\u95f4\u590d\u6742\u5ea6\u200b\u200b\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u200b<\/tr>\n<tbody>\n<tr>\n<td>\u67e5\u627e<\/td>\n<td>O(log N)<\/td>\n<td>O(N)<\/td>\n<\/tr>\n<tr>\n<td>\u63d2\u5165<\/td>\n<td>O(log N)<\/td>\n<td>O(N)<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664<\/td>\n<td>O(log N)<\/td>\n<td>O(N)<\/td>\n<\/tr>\n<tr>\n<td>\u4e0e\u6709\u5e8f\u6570\u7ec4\u3001\u94fe\u8868\u5bf9\u6bd4&#xff1a;<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\u200b\u6709\u5e8f\u6570\u7ec4\u200b&#xff1a;\u67e5\u8be2\u5feb&#xff08;O(log N)&#xff09;&#xff0c;\u4f46\u63d2\u5165\/\u5220\u9664\u6162&#xff08;O(N)&#xff09;&#xff1b;<\/li>\n<li>\u200b\u94fe\u8868\u200b&#xff1a;\u63d2\u5165\/\u5220\u9664\u5feb&#xff08;O(1)&#xff09;&#xff0c;\u4f46\u67e5\u8be2\u6162&#xff08;O(N)&#xff09;&#xff1b;<\/li>\n<li>\u200bBST\u200b&#xff1a;\u5728\u5e73\u8861\u65f6\u4e09\u8005\u5747\u4e3aO(log N)&#xff0c;\u7efc\u5408\u6548\u7387\u6700\u4f18\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>&#x1f6e0;\ufe0f \u200b\u4e94\u3001\u5e94\u7528\u573a\u666f\u200b<\/h4>\n<li>\n<p>\u200b\u52a8\u6001\u6570\u636e\u7ba1\u7406\u200b<\/p>\n<ul>\n<li>\u6570\u636e\u5e93\u7d22\u5f15&#xff08;\u5982B&#043;\u6811\u57fa\u4e8eBST\u601d\u60f3&#xff09;\u3002<\/li>\n<li>\u5b9e\u65f6\u5e93\u5b58\u7cfb\u7edf&#xff08;\u9891\u7e41\u63d2\u5165\/\u5220\u9664\u5546\u54c1\u5e93\u5b58&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u9ad8\u6548\u68c0\u7d22\u7cfb\u7edf\u200b<\/p>\n<ul>\n<li>\u5b57\u5178\u5b9e\u73b0&#xff08;\u5355\u8bcd\u68c0\u7d22&#xff09;\u3002<\/li>\n<li>\u6587\u4ef6\u7cfb\u7edf\u76ee\u5f55\u6811&#xff08;\u6309\u6587\u4ef6\u540d\u6392\u5e8f&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u8303\u56f4\u67e5\u8be2\u200b<\/p>\n<ul>\n<li>\u4e2d\u5e8f\u904d\u5386\u53ef\u5feb\u901f\u83b7\u53d6\u6709\u5e8f\u533a\u95f4&#xff08;\u5982\u6570\u636e\u5e93\u7684BETWEEN\u67e5\u8be2&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>&#x1f48e; \u200b\u603b\u7ed3\u200b<\/h4>\n<p>\u4e8c\u53c9\u641c\u7d22\u6811\u901a\u8fc7\u6709\u5e8f\u6027\u7ea6\u675f\u548c\u9012\u5f52\u5b50\u6811\u7ed3\u6784&#xff0c;\u5728\u52a8\u6001\u6570\u636e\u7ba1\u7406\u4e2d\u5b9e\u73b0\u4e86\u9ad8\u6548\u7684\u67e5\u8be2\u4e0e\u4fee\u6539\u3002\u5176\u6838\u5fc3\u4f18\u52bf\u5728\u4e8e\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u53ca\u5bf9\u6570\u7ea7\u64cd\u4f5c\u6548\u7387&#xff0c;\u4f46\u9700\u6ce8\u610f\u5e73\u8861\u6027\u95ee\u9898\u2014\u2014\u5b9e\u9645\u5e94\u7528\u4e2d\u5e38\u901a\u8fc7\u81ea\u5e73\u8861\u53d8\u79cd\u200b&#xff08;\u5982AVL\u3001\u7ea2\u9ed1\u6811&#xff09;\u89c4\u907f\u9000\u5316\u98ce\u9669\u3002\u7406\u89e3BST\u7684\u63d2\u5165\u3001\u5220\u9664\u903b\u8f91\u53ca\u6027\u80fd\u8fb9\u754c&#xff0c;\u662f\u8bbe\u8ba1\u9ad8\u6027\u80fd\u68c0\u7d22\u7cfb\u7edf\u7684\u57fa\u7840\u3002<\/p>\n<\/p>\n<p>\u7701\u6d41&#xff1a;<span style=\"color:#fe2c24\">\u5982\u679c\u4e00\u68f5\u6811\u5bf9\u5b83\u8fdb\u884c\u4e2d\u5e8f\u904d\u5386&#xff0c;\u5f97\u5230\u7684\u5e8f\u5217\u4e3a\u5347\u5e8f\u6392\u5217\u5219\u8fd9\u68f5\u6811\u4e3a\u4e8c\u53c9\u641c\u7d22\u6811<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u5e73\u8861\u4e8c\u53c9\u6811 \u662f\u6307\u5bf9\u4e8e\u4e00\u9897\u4e8c\u53c9\u641c\u7d22\u6811&#xff0c;\u8be5\u6811\u6240\u6709\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u7684\u9ad8\u5ea6\u76f8\u5dee\u4e0d\u8d85\u8fc7 1<\/span>\u3002<\/p>\n<\/p>\n<p>\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811&#xff08;Balanced Binary Search Tree&#xff0c;BBST&#xff09;\u662f\u4e00\u79cd\u901a\u8fc7\u7279\u5b9a\u89c4\u5219\u7ef4\u6301\u7ed3\u6784\u5e73\u8861\u7684\u4e8c\u53c9\u641c\u7d22\u6811&#xff0c;\u65e8\u5728\u89e3\u51b3\u666e\u901a\u4e8c\u53c9\u641c\u7d22\u6811&#xff08;BST&#xff09;\u5728\u52a8\u6001\u64cd\u4f5c\u4e2d\u53ef\u80fd\u9000\u5316\u6210\u94fe\u8868\u7684\u95ee\u9898&#xff0c;\u4ece\u800c\u4fdd\u8bc1\u6700\u574f\u60c5\u51b5\u4e0b\u7684\u64cd\u4f5c\u6548\u7387\u4e3a\u5bf9\u6570\u7ea7&#xff08;O(log n)&#xff09;\u3002\u4ee5\u4e0b\u662f\u5176\u7cfb\u7edf\u6027\u4ecb\u7ecd&#xff1a;<\/p>\n<hr \/>\n<h4>&#x1f333; \u4e00\u3001\u6838\u5fc3\u6982\u5ff5\u4e0e\u5b9a\u4e49<\/h4>\n<li>\n<p>\u200b\u57fa\u672c\u5b9a\u4e49\u200b<\/p>\n<ul>\n<li>\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u8981\u6c42\u4efb\u610f\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71\u200b&#xff08;\u5373\u5e73\u8861\u56e0\u5b50 \u2208 [-1, 0, 1]&#xff09;&#xff0c;\u4e14\u5de6\u53f3\u5b50\u6811\u81ea\u8eab\u4e5f\u5fc5\u987b\u662f\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u3002<\/li>\n<li>\u200b\u5e73\u8861\u56e0\u5b50&#xff08;Balance Factor&#xff09;\u200b\u200b&#xff1a;\u5b9a\u4e49\u4e3a\u5de6\u5b50\u6811\u9ad8\u5ea6\u51cf\u53bb\u53f3\u5b50\u6811\u9ad8\u5ea6&#xff0c;\u662f\u5224\u65ad\u8282\u70b9\u662f\u5426\u5931\u8861\u7684\u5173\u952e\u6307\u6807\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u6838\u5fc3\u76ee\u6807\u200b<\/p>\n<ul>\n<li>\u901a\u8fc7\u9650\u5236\u6811\u9ad8\u589e\u957f&#xff08;\u6811\u9ad8 h \u2248 O(log n)&#xff09;&#xff0c;\u786e\u4fdd\u67e5\u627e\u3001\u63d2\u5165\u3001\u5220\u9664\u64cd\u4f5c\u7684\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u7a33\u5b9a\u4e3a O(log n)\u200b&#xff0c;\u907f\u514d\u666e\u901aBST\u9000\u5316\u4e3a\u94fe\u8868&#xff08;\u64cd\u4f5c\u590d\u6742\u5ea6 O(n)&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u200b\u5173\u952e\u6027\u8d28\u200b<\/p>\n<ul>\n<li>\u200b\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u200b&#xff1a;\u7ee7\u627fBST\u7279\u6027&#xff0c;\u4e2d\u5e8f\u904d\u5386\u7ed3\u679c\u4e25\u683c\u9012\u589e\u3002<\/li>\n<li>\u200b\u9ad8\u5ea6\u5e73\u8861\u6027\u200b&#xff1a;\u6700\u5927\u6811\u9ad8\u53d7\u4e25\u683c\u7ea6\u675f&#xff08;\u5982AVL\u6811 h \u2264 1.44 log\u2082(n)&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>\u2699\ufe0f \u4e8c\u3001\u4e3b\u8981\u7c7b\u578b\u53ca\u6bd4\u8f83<\/h4>\n<p>\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u6709\u591a\u79cd\u5b9e\u73b0\u65b9\u5f0f&#xff0c;\u5176\u5e73\u8861\u7b56\u7565\u548c\u9002\u7528\u573a\u666f\u5404\u5f02&#xff1a;<\/p>\n<table>\n<tr>\u200b\u7c7b\u578b\u200b\u200b\u6838\u5fc3\u89c4\u5219\u200b\u200b\u5e73\u8861\u4e25\u683c\u6027\u200b\u200b\u9002\u7528\u573a\u666f\u200b<\/tr>\n<tbody>\n<tr>\n<td>\u200bAVL\u6811\u200b<\/td>\n<td>\u4efb\u610f\u8282\u70b9\u5e73\u8861\u56e0\u5b50\u7edd\u5bf9\u503c \u2264 1<\/td>\n<td>\u4e25\u683c\u5e73\u8861<\/td>\n<td>\u8bfb\u591a\u5199\u5c11&#xff08;\u5982\u9759\u6001\u7d22\u5f15\u3001\u79d1\u5b66\u8ba1\u7b97&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u200b\u7ea2\u9ed1\u6811\u200b<\/td>\n<td>1. \u6839\u4e0e\u53f6&#xff08;NIL&#xff09;\u4e3a\u9ed1<br \/>\n2. \u65e0\u8fde\u7eed\u7ea2\u8282\u70b9<br \/>\n3. \u6240\u6709\u8def\u5f84\u9ed1\u9ad8\u76f8\u540c<\/td>\n<td>\u5bbd\u677e\u5e73\u8861&#xff08;\u6700\u957f\u8def\u5f84 \u2264 2\u500d\u6700\u77ed\u8def\u5f84&#xff09;<\/td>\n<td>\u5199\u64cd\u4f5c\u9891\u7e41&#xff08;\u5982\u6570\u636e\u5e93\u3001STL map&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u200bTreap\u200b<\/td>\n<td>\u7ed3\u5408BST\u4e0e\u5806&#xff1a;\u8282\u70b9\u542b\u968f\u673a\u4f18\u5148\u7ea7&#xff0c;\u6309\u4f18\u5148\u7ea7\u8c03\u6574<\/td>\n<td>\u6982\u7387\u5e73\u8861<\/td>\n<td>\u7b80\u5355\u5b9e\u73b0\u3001\u4e2d\u7b49\u89c4\u6a21\u6570\u636e<\/td>\n<\/tr>\n<tr>\n<td>\u200bB\u6811\/B&#043;\u6811\u200b<\/td>\n<td>\u591a\u8def\u5e73\u8861&#xff1a;\u8282\u70b9\u53ef\u542b\u591a\u4e2a\u952e&#xff0c;\u51cf\u5c11\u78c1\u76d8I\/O<\/td>\n<td>\u8def\u5f84\u7b49\u957f<\/td>\n<td>\u5927\u89c4\u6a21\u6570\u636e\u5b58\u50a8&#xff08;\u6570\u636e\u5e93\u3001\u6587\u4ef6\u7cfb\u7edf&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200b\u6027\u80fd\u6743\u8861\u5bf9\u6bd4\u200b&#xff1a;<\/p>\n<ul>\n<li>\u200bAVL\u6811\u200b&#xff1a;\u67e5\u8be2\u6700\u4f18&#xff08;\u4e25\u683c\u5e73\u8861&#xff09;&#xff0c;\u4f46\u63d2\u5165\/\u5220\u9664\u9700\u9891\u7e41\u65cb\u8f6c&#xff0c;\u7ef4\u62a4\u6210\u672c\u9ad8\u3002<\/li>\n<li>\u200b\u7ea2\u9ed1\u6811\u200b&#xff1a;\u63d2\u5165\/\u5220\u9664\u4ec5\u9700 O(1) \u65cb\u8f6c &#043; \u989c\u8272\u8c03\u6574&#xff0c;\u7efc\u5408\u6027\u80fd\u66f4\u9002\u5e94\u52a8\u6001\u6570\u636e\u3002<\/li>\n<li>\u200bB&#043;\u6811\u200b&#xff1a;\u4e13\u4e3a\u78c1\u76d8\u8bbe\u8ba1&#xff0c;\u901a\u8fc7\u591a\u952e\u8282\u70b9\u964d\u4f4eI\/O\u6b21\u6570&#xff0c;\u9002\u5408\u6570\u636e\u5e93\u7d22\u5f15\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>&#x1f527; \u4e09\u3001\u5e73\u8861\u7ef4\u62a4\u673a\u5236<\/h4>\n<h5>1. \u200b\u65cb\u8f6c\u64cd\u4f5c&#xff08;\u6838\u5fc3\u8c03\u6574\u624b\u6bb5&#xff09;\u200b\u200b<\/h5>\n<ul>\n<li>\u200b\u5de6\u65cb\u200b&#xff1a;\u5f53\u53f3\u5b50\u6811\u8fc7\u9ad8\u65f6&#xff0c;\u63d0\u5347\u53f3\u5b50\u8282\u70b9\u4e3a\u7236\u8282\u70b9&#xff0c;\u539f\u7236\u8282\u70b9\u964d\u4e3a\u5de6\u5b50\u8282\u70b9\u3002<\/li>\n<li>\u200b\u53f3\u65cb\u200b&#xff1a;\u5f53\u5de6\u5b50\u6811\u8fc7\u9ad8\u65f6&#xff0c;\u63d0\u5347\u5de6\u5b50\u8282\u70b9\u4e3a\u7236\u8282\u70b9&#xff0c;\u539f\u7236\u8282\u70b9\u964d\u4e3a\u53f3\u5b50\u8282\u70b9\u3002<\/li>\n<li>\u200b\u53cc\u65cb&#xff08;LR\/RL&#xff09;\u200b\u200b&#xff1a;\u7528\u4e8e\u5b50\u6811\u65b9\u5411\u4e0e\u7236\u8282\u70b9\u5931\u8861\u65b9\u5411\u4e0d\u4e00\u81f4\u7684\u573a\u666f&#xff08;\u5982LR\u578b&#xff1a;\u5148\u5de6\u65cb\u5b50\u8282\u70b9&#xff0c;\u518d\u53f3\u65cb\u7236\u8282\u70b9&#xff09;\u3002<\/li>\n<\/ul>\n<h5>2. \u200b\u5931\u8861\u68c0\u6d4b\u4e0e\u4fee\u590d\u6d41\u7a0b\u200b<\/h5>\n<ul>\n<li>\u200b\u63d2\u5165\/\u5220\u9664\u540e\u200b&#xff1a;\u4ece\u64cd\u4f5c\u70b9\u56de\u6eaf\u81f3\u6839\u8282\u70b9&#xff0c;\u66f4\u65b0\u8def\u5f84\u4e0a\u5404\u8282\u70b9\u7684\u9ad8\u5ea6\u53ca\u5e73\u8861\u56e0\u5b50\u3002<\/li>\n<li>\u200b\u89e6\u53d1\u6761\u4ef6\u200b&#xff1a;\u82e5\u5e73\u8861\u56e0\u5b50\u8d85\u51fa [-1, 1]&#xff0c;\u6839\u636e\u5931\u8861\u7c7b\u578b&#xff08;LL\/RR\/LR\/RL&#xff09;\u6267\u884c\u76f8\u5e94\u65cb\u8f6c\u3002<\/li>\n<\/ul>\n<h5>3. \u200b\u7ea2\u9ed1\u6811\u7684\u7279\u6b8a\u8c03\u6574\u200b<\/h5>\n<ul>\n<li>\u901a\u8fc7\u989c\u8272\u7ffb\u8f6c\u548c\u65cb\u8f6c\u4fee\u590d\u8fde\u7eed\u7ea2\u8282\u70b9\u6216\u9ed1\u9ad8\u4e0d\u4e00\u81f4\u95ee\u9898&#xff0c;\u5982\u63d2\u5165\u540e\u7684\u4e09\u79cd\u60c5\u51b5&#xff08;Case&#xff09;\u5904\u7406\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u23f1\ufe0f \u56db\u3001\u6027\u80fd\u5206\u6790<\/h4>\n<li>\n<p>\u200b\u65f6\u95f4\u590d\u6742\u5ea6\u200b<\/p>\n<table>\n<tr>\u200b\u64cd\u4f5c\u200b\u200b\u65f6\u95f4\u590d\u6742\u5ea6\u200b\u200b\u539f\u56e0\u200b<\/tr>\n<tbody>\n<tr>\n<td>\u67e5\u627e<\/td>\n<td>O(log n)<\/td>\n<td>\u6811\u9ad8\u53d7\u5e73\u8861\u7ea6\u675f<\/td>\n<\/tr>\n<tr>\n<td>\u63d2\u5165<\/td>\n<td>O(log n)<\/td>\n<td>\u56de\u6eaf\u8def\u5f84\u957f\u5ea6 \u2264 \u6811\u9ad8<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u9664<\/td>\n<td>O(log n)<\/td>\n<td>\u9700\u65cb\u8f6c\u8c03\u6574\u4f46\u8def\u5f84\u4ecd\u5bf9\u6570\u7ea7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\n<p>\u200b\u4e0e\u666e\u901aBST\u7684\u5bf9\u6bd4\u200b<\/p>\n<ul>\n<li>\u200bBST\u9000\u5316\u98ce\u9669\u200b&#xff1a;\u6709\u5e8f\u63d2\u5165\u5e8f\u5217&#xff08;\u5982 1\u21922\u21923\u2192\u2026&#xff09;\u5bfc\u81f4\u6811\u9ad8 &#061; n&#xff0c;\u64cd\u4f5c\u9000\u5316\u4e3a O(n)\u3002<\/li>\n<li>\u200b\u5e73\u8861\u6811\u4f18\u52bf\u200b&#xff1a;\u52a8\u6001\u7ef4\u62a4\u5e73\u8861\u6027&#xff0c;\u4fdd\u8bc1\u64cd\u4f5c\u6548\u7387\u7a33\u5b9a\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>&#x1f6e0;\ufe0f \u4e94\u3001\u5e94\u7528\u573a\u666f<\/h4>\n<li>\u200b\u6570\u636e\u5e93\u7cfb\u7edf\u200b\n<ul>\n<li>B&#043;\u6811\u7528\u4e8e\u7d22\u5f15\u7ed3\u6784&#xff0c;\u52a0\u901f\u8303\u56f4\u67e5\u8be2\u4e0e\u6392\u5e8f&#xff08;\u5982 MySQL InnoDB \u5f15\u64ce&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200b\u8bed\u8a00\u6807\u51c6\u5e93\u200b\n<ul>\n<li>\u7ea2\u9ed1\u6811\u5b9e\u73b0\u5173\u8054\u5bb9\u5668&#xff08;\u5982 C&#043;&#043; STL \u7684 std::map\u3001Java TreeMap&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200b\u6587\u4ef6\u7cfb\u7edf\u4e0e\u5185\u5b58\u7ba1\u7406\u200b\n<ul>\n<li>\u5e73\u8861\u6811\u9ad8\u6548\u652f\u6301\u52a8\u6001\u6570\u636e\u589e\u5220&#xff08;\u5982 Linux \u5185\u6838\u8c03\u5ea6\u5668&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u200b\u5b9e\u65f6\u8ba1\u7b97\u7cfb\u7edf\u200b\n<ul>\n<li>Treap \u6216 AVL \u6811\u7528\u4e8e\u9700\u5feb\u901f\u68c0\u7d22\u7684\u52a8\u6001\u6570\u636e\u96c6&#xff08;\u5982\u5b9e\u65f6\u5e93\u5b58\u66f4\u65b0&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<hr \/>\n<h4>&#x1f48e; \u603b\u7ed3<\/h4>\n<p>\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u901a\u8fc7\u9ad8\u5ea6\u7ea6\u675f\u4e0e\u52a8\u6001\u8c03\u6574\u673a\u5236\u200b&#xff08;\u65cb\u8f6c\/\u989c\u8272\u8c03\u6574&#xff09;&#xff0c;\u5728\u4fdd\u6301\u6709\u5e8f\u6027\u7684\u540c\u65f6\u5c06\u64cd\u4f5c\u590d\u6742\u5ea6\u9501\u5b9a\u4e8e O(log n)\u3002\u5176\u4e0d\u540c\u7c7b\u578b\u5404\u6709\u4fa7\u91cd&#xff1a;<\/p>\n<ul>\n<li>\u200b\u4e25\u683c\u5e73\u8861\u9009 AVL&#xff08;\u67e5\u8be2\u5bc6\u96c6\u578b\u573a\u666f&#xff09;&#xff1b;<\/li>\n<li>\u200b\u9ad8\u5e76\u53d1\u52a8\u6001\u6570\u636e\u9009\u7ea2\u9ed1\u6811&#xff08;\u5de5\u7a0b\u5b9e\u8df5\u9996\u9009&#xff09;&#xff1b;<\/li>\n<li>\u200b\u6d77\u91cf\u5b58\u50a8\u7528 B&#043; \u6811&#xff08;\u4f18\u5316\u78c1\u76d8 I\/O&#xff09;\u3002<br \/>\n\u7406\u89e3\u5176\u5e73\u8861\u539f\u7406\u4e0e\u5b9e\u73b0\u5dee\u5f02&#xff0c;\u662f\u8bbe\u8ba1\u9ad8\u6027\u80fd\u68c0\u7d22\u7cfb\u7edf\u7684\u5173\u952e\u57fa\u7840\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb26\u6b21\u3002\u200b\u57fa\u672c\u5b9a\u4e49\u200b\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u8981\u6c42\u4efb\u610f\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71\u200b\uff08\u5373\u5e73\u8861\u56e0\u5b50 \u2208 [-1, 0, 1]\uff09\uff0c\u4e14\u5de6\u53f3\u5b50\u6811\u81ea\u8eab\u4e5f\u5fc5\u987b\u662f\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u3002\u200b\u5e73\u8861\u56e0\u5b50\uff08Balance Factor\uff09\u200b\u200b\uff1a\u5b9a\u4e49\u4e3a\u5de6\u5b50\u6811\u9ad8\u5ea6\u51cf\u53bb\u53f3\u5b50\u6811\u9ad8\u5ea6\uff0c\u662f\u5224\u65ad\u8282\u70b9\u662f\u5426\u5931\u8861\u7684\u5173\u952e\u6307\u6807\u3002\u200b\u6838\u5fc3\u76ee\u6807\u200b\u901a\u8fc7\u9650\u5236\u6811\u9ad8\u589e\u957f\uff08\u6811\u9ad8 h \u2248 O(log n)\uff09\uff0c\u786e\u4fdd\u67e5\u627e\u3001\u63d2\u5165\u3001\u5220\u9664\u64cd\u4f5c\u7684\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u7a33\u5b9a\u4e3a O(log n)\u200b\uff0c\u907f\u514d\u666e\u901aBST\u9000\u5316\u4e3a\u94fe\u8868\uff08\u64cd\u4f5c\u590d\u6742\u5ea6 O(n)\uff09\u3002\u200b\u5173\u952e\u6027\u8d28\u200b\u200b\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1813,427],"topic":[],"class_list":["post-57770","post","type-post","status-publish","format-standard","hentry","category-server","tag-1813","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \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\/57770.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb26\u6b21\u3002\u200b\u57fa\u672c\u5b9a\u4e49\u200b\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u8981\u6c42\u4efb\u610f\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71\u200b\uff08\u5373\u5e73\u8861\u56e0\u5b50 \u2208 [-1, 0, 1]\uff09\uff0c\u4e14\u5de6\u53f3\u5b50\u6811\u81ea\u8eab\u4e5f\u5fc5\u987b\u662f\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u3002\u200b\u5e73\u8861\u56e0\u5b50\uff08Balance Factor\uff09\u200b\u200b\uff1a\u5b9a\u4e49\u4e3a\u5de6\u5b50\u6811\u9ad8\u5ea6\u51cf\u53bb\u53f3\u5b50\u6811\u9ad8\u5ea6\uff0c\u662f\u5224\u65ad\u8282\u70b9\u662f\u5426\u5931\u8861\u7684\u5173\u952e\u6307\u6807\u3002\u200b\u6838\u5fc3\u76ee\u6807\u200b\u901a\u8fc7\u9650\u5236\u6811\u9ad8\u589e\u957f\uff08\u6811\u9ad8 h \u2248 O(log n)\uff09\uff0c\u786e\u4fdd\u67e5\u627e\u3001\u63d2\u5165\u3001\u5220\u9664\u64cd\u4f5c\u7684\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u7a33\u5b9a\u4e3a O(log n)\u200b\uff0c\u907f\u514d\u666e\u901aBST\u9000\u5316\u4e3a\u94fe\u8868\uff08\u64cd\u4f5c\u590d\u6742\u5ea6 O(n)\uff09\u3002\u200b\u5173\u952e\u6027\u8d28\u200b\u200b\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57770.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-15T11:40:02+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57770.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57770.html\",\"name\":\"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T11:40:02+00:00\",\"dateModified\":\"2025-08-15T11:40:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57770.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57770.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57770.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd\"}]},{\"@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":"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \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\/57770.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb26\u6b21\u3002\u200b\u57fa\u672c\u5b9a\u4e49\u200b\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u8981\u6c42\u4efb\u610f\u8282\u70b9\u7684\u5de6\u53f3\u5b50\u6811\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e0d\u8d85\u8fc71\u200b\uff08\u5373\u5e73\u8861\u56e0\u5b50 \u2208 [-1, 0, 1]\uff09\uff0c\u4e14\u5de6\u53f3\u5b50\u6811\u81ea\u8eab\u4e5f\u5fc5\u987b\u662f\u5e73\u8861\u4e8c\u53c9\u641c\u7d22\u6811\u3002\u200b\u5e73\u8861\u56e0\u5b50\uff08Balance Factor\uff09\u200b\u200b\uff1a\u5b9a\u4e49\u4e3a\u5de6\u5b50\u6811\u9ad8\u5ea6\u51cf\u53bb\u53f3\u5b50\u6811\u9ad8\u5ea6\uff0c\u662f\u5224\u65ad\u8282\u70b9\u662f\u5426\u5931\u8861\u7684\u5173\u952e\u6307\u6807\u3002\u200b\u6838\u5fc3\u76ee\u6807\u200b\u901a\u8fc7\u9650\u5236\u6811\u9ad8\u589e\u957f\uff08\u6811\u9ad8 h \u2248 O(log n)\uff09\uff0c\u786e\u4fdd\u67e5\u627e\u3001\u63d2\u5165\u3001\u5220\u9664\u64cd\u4f5c\u7684\u6700\u574f\u65f6\u95f4\u590d\u6742\u5ea6\u7a33\u5b9a\u4e3a O(log n)\u200b\uff0c\u907f\u514d\u666e\u901aBST\u9000\u5316\u4e3a\u94fe\u8868\uff08\u64cd\u4f5c\u590d\u6742\u5ea6 O(n)\uff09\u3002\u200b\u5173\u952e\u6027\u8d28\u200b\u200b\u4e2d\u5e8f\u904d\u5386\u6709\u5e8f\u6027\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/57770.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T11:40:02+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57770.html","url":"https:\/\/www.wsisp.com\/helps\/57770.html","name":"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T11:40:02+00:00","dateModified":"2025-08-15T11:40:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57770.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57770.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57770.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e8c\u53c9\u641c\u7d22\u6811\u7684\u6982\u5ff5\u548c\u8be6\u7ec6\u4ecb\u7ecd"}]},{"@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\/57770","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=57770"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57770\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57770"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}