{"id":39861,"date":"2023-12-11T14:49:03","date_gmt":"2023-12-11T06:49:03","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=39861"},"modified":"2023-12-11T14:49:03","modified_gmt":"2023-12-11T06:49:03","slug":"java%e7%89%88%e5%bf%ab%e9%80%9f%e6%8e%92%e5%ba%8f%e4%b8%8d%e7%a8%b3%e5%ae%9a","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/java%e7%89%88%e5%bf%ab%e9%80%9f%e6%8e%92%e5%ba%8f%e4%b8%8d%e7%a8%b3%e5%ae%9a\/","title":{"rendered":"Java\u7248\u5feb\u901f\u6392\u5e8f[\u4e0d\u7a33\u5b9a]"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u539f\u7406\uff1a\u5206\u6cbb+\u9012\u5f52<\/p>\n<p>\u590d\u6742\u5ea6\uff1aO(nlgn) &#8211; O(nlgn) &#8211; O(n^2) &#8211; O(1)[\u5e73\u5747 &#8211; \u6700\u597d &#8211; \u6700\u574f &#8211; \u7a7a\u95f4\u590d\u6742\u5ea6]<\/p>\n<p>\u6808\u7a7a\u95f40(lgn) &#8211; O(n)<\/p>\n<p>&lt;pre&gt;&lt;code class=&quot;&quot;language-java&quot;&quot; lang=&quot;&quot;java&quot;&quot;&gt;\/\/ \u56fa\u5b9a\u57fa\u51c6<br \/>\npublic void quickSort(int[] a, int low, int high) {<br \/>\n        if (null == a || a.length &lt; 2) {<br \/>\n            return;<br \/>\n        }<br \/>\n        if (low &lt; high) {<br \/>\n            int mid = partition(a, low, high);<br \/>\n            quickSort(a, low, mid-1);<br \/>\n            quickSort(a, mid+1, high);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    private int partition(int[] a, int low, int high) {<br \/>\n        int pivot = a[low];<\/p>\n<p>        while (low &lt; high) {<br \/>\n            \/\/ \u6ce8\u610f\u7b49\u4e8e\uff0c\u5426\u5219\u6b7b\u5faa\u73af<br \/>\n            while (low &lt; high &amp;&amp; a[high] &gt;= pivot) {<br \/>\n                high&#8211;;<br \/>\n            }<br \/>\n            a[low] = a[high];<br \/>\n            \/\/ \u6ce8\u610f\u7b49\u4e8e\uff0c\u5426\u5219\u6b7b\u5faa\u73af<br \/>\n            while (low &lt; high &amp;&amp; a[low] &lt;= pivot) {<br \/>\n                low++;<br \/>\n            }<br \/>\n            a[high] = a[low];<br \/>\n        }<br \/>\n        a[low] = pivot;<\/p>\n<p>        return low;<br \/>\n    }<br \/>\n&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u539f\u7406\uff1a\u5206\u6cbb+\u9012\u5f52 \u590d\u6742\u5ea6\uff1aO(nlgn) &#8211; O(nlgn) &#038;# [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-39861","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/39861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=39861"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/39861\/revisions"}],"predecessor-version":[{"id":39862,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/39861\/revisions\/39862"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=39861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=39861"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=39861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}