{"id":1029,"date":"2022-02-25T22:34:26","date_gmt":"2022-02-25T14:34:26","guid":{"rendered":"http:\/\/eotstxtab.top\/?p=1029"},"modified":"2022-02-25T23:04:06","modified_gmt":"2022-02-25T15:04:06","slug":"%e6%8e%92%e5%ba%8f%e7%ae%97%e6%b3%95%e5%b0%8f%e8%ae%ba","status":"publish","type":"post","link":"http:\/\/43.142.23.155\/?p=1029","title":{"rendered":"\u6392\u5e8f\u7b97\u6cd5\u5c0f\u8bba"},"content":{"rendered":"\n<p style=\"font-size:30px\">\u6982\u5ff5\uff1a<\/p>\n\n\n\n<p>\u6392\u5e8f\uff1a \u5c06\u4e00\u4e2a\u6570\u636e\u5143\u7d20\u7684\u4efb\u610f\u5e8f\u5217\u91cd\u65b0\u6392\u5217\u6210\u4e00\u4e2a\u6309\u5173\u952e\u5b57\u6709\u5e8f\u7684\u5e8f\u5217\uff1b<\/p>\n\n\n\n<p>\u5185\u90e8\u6392\u5e8f\uff1a \u5f85\u6392\u5e8f\u7684\u8bb0\u5f55\u5b58\u653e\u5728\u8ba1\u7b97\u673a\u7684\u5185\u5b58\u4e2d\u6240\u8fdb\u884c\u7684\u6392\u5e8f\u64cd\u4f5c\u79f0\u4e3a\u5185\u90e8\u6392\u5e8f\uff1b<\/p>\n\n\n\n<p>\u5916\u90e8\u6392\u5e8f\uff1a \u5f85\u6392\u5e8f\u7684\u8bb0\u5f55\u6570\u91cf\u5f88\u5927\uff0c\u4ee5\u81f4\u5185\u5b58\u4e00\u6b21\u4e0d\u80fd\u5bb9\u7eb3\u5168\u90e8\u8bb0\u5f55\uff0c\u5728\u6392\u5e8f\u8fc7\u7a0b\u4e2d\u9700\u8981\u8bbf\u95ee\u5916\u5b58\u7684\u6392\u5e8f\u8fc7\u7a0b\u79f0\u4e3a\u5916\u90e8\u6392\u5e8f\uff1b<\/p>\n\n\n\n<p>\u7a33\u5b9a\u7684\u6392\u5e8f\uff1a \u6bd4\u5982\u4e00\u4e2a\u5e8f\u5217\u662f\u201c1,4,3,3<em>,2\u201d\uff0c\u6309\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\u540e\u53d8\u6210\u201c1,2,3,3<\/em> ,4\u201d\uff0c\u5c31\u53eb\u505a\u7a33\u5b9a\u6392\u5e8f\uff0c\u53733\u548c3*\u76f8\u5bf9\u987a\u5e8f\u4e0d\u53d8\u3002<\/p>\n\n\n\n<p><strong>\u65f6\u95f4\u590d\u6742\u5ea6\u4e00\u822c\u7531\u6bd4\u8f83\u548c\u79fb\u52a8\u6b21\u6570\u51b3\u5b9a<\/strong><\/p>\n\n\n\n<p style=\"font-size:30px\">\u4e00\u3001\u63d2\u5165\u6392\u5e8f<\/p>\n\n\n\n<p class=\"has-medium-font-size\">1\u3001\u76f4\u63a5\u63d2\u5165<\/p>\n\n\n\n<p><strong>\u57fa\u672c\u601d\u60f3\uff1a<\/strong>\u00a0n\u4e2a\u5f85\u6392\u5e8f\u7684\u5143\u7d20\u7531\u4e00\u4e2a\u6709\u5e8f\u8868\u548c\u4e00\u4e2a\u65e0\u5e8f\u8868\u7ec4\u6210\uff0c\u5f00\u59cb\u65f6\u6709\u5e8f\u8868\u4e2d\u53ea\u5305\u542b\u4e00\u4e2a\u5143\u7d20\u3002\u6392\u5e8f\u8fc7\u7a0b\u4e2d\uff0c\u6bcf\u6b21\u4ece\u65e0\u5e8f\u8868\u4e2d\u53d6\u51fa\u7b2c\u4e00\u4e2a\u5143\u7d20\uff0c\u5c06\u5176\u63d2\u5165\u5230\u6709\u5e8f\u8868\u4e2d\u7684\u9002\u5f53\u4f4d\u7f6e\uff0c\u4f7f\u6709\u5e8f\u8868\u7684\u957f\u5ea6\u4e0d\u65ad\u52a0\u957f\uff0c\u5b8c\u6210\u6392\u5e8f\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size\">2\u3001\u4e8c\u5206\u63d2\u5165<\/p>\n\n\n\n<p><strong>\u6298\u534a\u63d2\u5165\u6392\u5e8f\u4ec5\u51cf\u5c11\u4e86\u6bd4\u8f83\u5143\u7d20\u7684\u6b21\u6570<\/strong>\uff0c\u8be5\u6bd4\u8f83\u6b21\u6570\u4e0e\u5f85\u6392\u5e8f\u8868\u7684\u521d\u59cb\u72b6\u6001\u65e0\u5173\uff0c\u4ec5\u53d6\u51b3\u4e8e\u8868\u4e2d\u7684\u5143\u7d20\u4e2a\u6570n\uff0c\u800c\u5143\u7d20\u7684\u79fb\u52a8\u6b21\u6570\u5e76\u672a\u6539\u53d8\uff0c\u5b83\u4f9d\u8d56\u4e8e\u5f85\u6392\u5e8f\u8868\u7684\u521d\u59cb\u72b6\u6001\uff1b<br>\u65f6\u95f4\u590d\u6742\u5ea6\u4ecd\u4e3aO(n<sup>2<\/sup>)\uff1b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void   InsertSort(SqList &amp;L)   \/* \u5bf9\u987a\u5e8f\u8868L\u4f5c\u6298\u534a\u63d2\u5165\u6392\u5e8f *\/\r\n{\t\r\n        for(i=2\uff1bi &lt;= L.length; i++) \r\n        {   L.r&#91;0] = L.r&#91;i];                \/* \u4fdd\u5b58\u5f85\u63d2\u5165\u5143\u7d20 *\/\r\n             low = 1\uff1bhigh = i-1\uff1b    \/* \u8bbe\u7f6e\u521d\u59cb\u533a\u95f4 *\/\r\n             while(low &lt;= high)       \/* \u786e\u5b9a\u63d2\u5165\u4f4d\u7f6e *\/\r\n             {   mid = (low+high)\/2\uff1b\r\n                  if (L.r&#91;0].key > L.r&#91;mid].key)\r\n                       low = mid+1\uff1b      \/* \u63d2\u5165\u4f4d\u7f6e\u5728\u9ad8\u534a\u533a\u4e2d *\/\r\n                  else  high = mid-1\uff1b   \/* \u63d2\u5165\u4f4d\u7f6e\u5728\u4f4e\u534a\u533a\u4e2d *\/\r\n             }\/* while *\/\r\n             for(j = i - 1; j >= high +1;  j--) \/* high+1\u4e3a\u63d2\u5165\u4f4d\u7f6e *\/\r\n                 L.r&#91;j+1] = L.r&#91;j];          \/* \u540e\u79fb\u5143\u7d20\uff0c\u7559\u51fa\u63d2\u5165\u7a7a\u4f4d *\/\r\n             L.r&#91;high+1] = L.r&#91;0];      \/* \u5c06\u5143\u7d20\u63d2\u5165 *\/\r\n         }\/* for *\/\r\n}\/* InsertSort *\/\r\n\r\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">3\u3001\u5e0c\u5c14\u6392\u5e8f<\/p>\n\n\n\n<p><strong>\u7b97\u6cd5\u601d\u60f3\uff1a<\/strong>\u00a0\u5148\u5c06\u6574\u4e2a\u5f85\u6392\u5e8f\u5143\u7d20\u5e8f\u5217<strong>\u5206\u5272\u6210\u82e5\u5e72\u4e2a\u5b50\u5e8f\u5217<\/strong>\uff08\u7531\u76f8\u9694\u67d0\u4e2a\u201c<strong>\u589e\u91cf<\/strong>\u201d\u7684\u5143\u7d20\u7ec4\u6210\u7684\uff09\uff0c\u5206\u522b\u8fdb\u884c\u76f4\u63a5\u63d2\u5165\u6392\u5e8f\uff0c\u5f85\u6574\u4e2a\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\u57fa\u672c\u6709\u5e8f\uff08\u589e\u91cf\u8db3\u591f\u5c0f\uff09\u65f6\uff0c\u518d\u5bf9\u5168\u4f53\u5143\u7d20\u8fdb\u884c\u4e00\u6b21\u76f4\u63a5\u63d2\u5165\u6392\u5e8f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2022\/02\/image-15.png\" alt=\"\" class=\"wp-image-1040\" width=\"703\" height=\"422\" srcset=\"http:\/\/43.142.23.155\/wp-content\/uploads\/2022\/02\/image-15.png 845w, http:\/\/43.142.23.155\/wp-content\/uploads\/2022\/02\/image-15-300x181.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>void ShellInsert(SqlList &amp;L, int dk){\r\n\tfor(int i=dk+1; i&lt;=L.length;i++){\/\/\u628a\u6240\u6709\u7ec4\u90fd\u904d\u5386\u4e00\u904d\r\n\t\tif(L.r&#91;i].key&lt;L.r&#91;i-dk].key){\r\n\t\t\tL.r&#91;0]=L.r&#91;i];\r\n\t\t\tfor(int j = i-dk; j>0&amp;&amp;L.r&#91;0].key&lt;L.r&#91;j].key; j-=dk){\r\n\t\t\t\tL.r&#91;j+dk]=L.r&#91;j];\/\/\u540e\u632a\r\n\t\t\t}\r\n\t\t\tL.r&#91;j+dk]=L.r&#91;0];\/\/\u63d2\u5165\r\n\t\t}\r\n\t\r\n\t}\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>\u6700\u7ec8\u589e\u91cfdk\u7684\u503c\u4e00\u5b9a\u662f1\uff0c\u4e0d\u7136\u6ca1\u529e\u6cd5\u628a\u6574\u4e2a\u5e8f\u5217\u90fd\u6392\u5e8f<\/p>\n\n\n\n<p class=\"has-medium-font-size\">\u4e8c\u3001\u4ea4\u6362\u6392\u5e8f<\/p>\n\n\n\n<p>1\u3001\u5192\u6ce1\u6392\u5e8f<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>2\u3001\u5feb\u901f\u6392\u5e8f<\/p>\n\n\n\n<p>\u5feb\u6392\u662f\u76ee\u524d\u6240\u6709\u5185\u6392\u5e8f\u7b97\u6cd5\u4e2d\u901f\u5ea6\u6700\u5feb\u7684\u4e00\u79cd<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u5ff5\uff1a \u6392\u5e8f\uff1a \u5c06\u4e00\u4e2a\u6570\u636e\u5143\u7d20\u7684\u4efb\u610f\u5e8f\u5217\u91cd\u65b0\u6392\u5217\u6210\u4e00\u4e2a\u6309\u5173\u952e\u5b57\u6709\u5e8f\u7684\u5e8f\u5217\uff1b \u5185\u90e8\u6392\u5e8f\uff1a \u5f85\u6392\u5e8f\u7684\u8bb0\u5f55\u5b58\u653e\u5728\u8ba1\u7b97\u673a\u7684\u5185\u5b58\u4e2d\u6240\u8fdb\u884c\u7684\u6392\u5e8f\u64cd\u4f5c\u79f0\u4e3a\u5185\u90e8\u6392\u5e8f\uff1b \u5916\u90e8\u6392\u5e8f\uff1a \u5f85\u6392\u5e8f\u7684\u8bb0\u5f55\u6570\u91cf\u5f88\u5927\uff0c\u4ee5\u81f4\u5185\u5b58\u4e00\u6b21\u4e0d&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,54],"tags":[53,55],"class_list":["post-1029","post","type-post","status-publish","format-standard","hentry","category-9","category-54","tag-c","tag-55"],"_links":{"self":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/1029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1029"}],"version-history":[{"count":16,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/1029\/revisions"}],"predecessor-version":[{"id":1048,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/1029\/revisions\/1048"}],"wp:attachment":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1029"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}