{"id":44031,"date":"2023-12-11T15:01:38","date_gmt":"2023-12-11T07:01:38","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=44031"},"modified":"2023-12-11T15:01:38","modified_gmt":"2023-12-11T07:01:38","slug":"%e8%af%b7%e7%94%a8js%e5%86%99%e5%87%ba%e5%87%a0%e7%a7%8d%e5%b8%b8%e8%a7%81%e7%9a%84%e6%8e%92%e5%ba%8f%e7%ae%97%e6%b3%95%ef%bc%9f-2","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e8%af%b7%e7%94%a8js%e5%86%99%e5%87%ba%e5%87%a0%e7%a7%8d%e5%b8%b8%e8%a7%81%e7%9a%84%e6%8e%92%e5%ba%8f%e7%ae%97%e6%b3%95%ef%bc%9f-2\/","title":{"rendered":"\u8bf7\u7528js\u5199\u51fa\u51e0\u79cd\u5e38\u89c1\u7684\u6392\u5e8f\u7b97\u6cd5\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;                    \u53c2\u8003\u56de\u7b54\uff1a<\/p>\n<p>\u57fa\u672c\u6392\u5e8f\u7b97\u6cd5\uff1a\u5192\u6ce1\uff0c\u9009\u62e9\uff0c\u63d2\u5165\uff0c\u5e0c\u5c14\uff0c\u5f52\u5e76\uff0c\u5feb\u6392<\/p>\n<p>&lt;strong&gt;\u5192\u6ce1\u6392\u5e8f\uff1a&lt;\/strong&gt;&lt;\/p&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function bubbleSort(data){    var temp=0;    for(var i=data.length;i&gt;0;i&#8211;){        for(var j=0;j&lt;i-1;j++){            if(data[j]&gt;data[j+1])            {            temp=data[j];            data[j]=data[j+1];            data[j+1]=temp;            }        }    }    return data;}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;strong&gt;\u9009\u62e9\u6392\u5e8f\uff1a&lt;\/strong&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function selectionSort(data){    for(var i=0;i&lt;data.length;i++){    var min=data[i];    var temp;    var index=1;    for(var j=i+1;j&lt;data.length;j++){        if(data[j]&lt;min)        {            temp=data[j];            data[j]=min;            min=temp;        }    }    temp=data[i];    data[i]=min;    data[index]=temp}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;strong&gt;\u63d2\u5165\u6392\u5e8f\uff1a&lt;\/strong&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function insertSort(data){    var len=data.length;    for(var i=0;i&lt;len;i++){        var key=data[i];        var j=i-1;        while(j&gt;=0&amp;&amp;data[j]&gt;key){            data[j+1]=data[i];            j&#8211;;        }        data[j+1]=key;    }    return data;}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;strong&gt;\u5e0c\u5c14\u6392\u5e8f\uff1a&lt;\/strong&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function shallSort(array) {    var increment = array.length;    var i;    var temp; \/\/\u6682\u5b58    do {    \/\/\u8bbe\u7f6e\u589e\u91cf    increment = Math.floor(increment \/ 3) + 1;    for (i = increment ; i &lt; array.length; i++) {        if ( array[i] &lt; array[i &#8211; increment]) {            temp = array[i];            for (var j = i &#8211; increment; j &gt;= 0 &amp;&amp; temp &lt; array[j]; j -= increment) {                array[j + increment] = array[j];            }            array[j + increment] = temp;            }        }    }    while (increment &gt; 1)    return array;}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;strong&gt;\u5f52\u5e76\u6392\u5e8f\uff1a&lt;\/strong&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function mergeSort ( array ) {    var len = array.length;    if( len &lt; 2 ){   \t \treturn array;    }    var middle = Math.floor(len \/ 2),    left = array.slice(0, middle),    right = array.slice(middle);    return merge(mergeSort(left), mergeSort(right));}function merge(left, right){    var result = [];    while (left.length &amp;&amp; right.length) {        if (left[0] &lt;= right[0]) {            result.push(left.shift());        } else {            result.push(right.shift());        }    }    while (left.length)    \tresult.push(left.shift());    while (right.length)    \tresult.push(right.shift());    return result;}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>&lt;strong&gt;\u5feb\u901f\u6392\u5e8f&lt;\/strong&gt;<\/p>\n<p>&lt;pre&gt;&lt;code&gt;function quickSort(arr){    if(arr.length==0)    \treturn [];    var left=[];    var right=[];    var pivot=arr[0];    for(var i=0;i&lt;arr.length;i++){        if(arr[i]&lt;pivot){        \tleft.push(arr[i]);    \t}        else{            right.push(arr[i]);        }    }    return quickSort(left).concat(pivot,quickSort(right));}&lt;\/code&gt;&lt;\/pre&gt;<\/p>\n<p>\u00a0<\/p>\n<p>&lt;pre&gt;&lt;code&gt;            &quot;&#8220;`<br \/>\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; \u53c2\u8003\u56de\u7b54\uff1a \u57fa\u672c\u6392\u5e8f\u7b97\u6cd5\uff1a\u5192\u6ce1\uff0c\u9009\u62e9\uff0c\u63d2\u5165\uff0c\u5e0c\u5c14\uff0c\u5f52\u5e76\uff0c\u5feb\u6392 &lt;stro [&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-44031","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/44031","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=44031"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/44031\/revisions"}],"predecessor-version":[{"id":44032,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/44031\/revisions\/44032"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=44031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=44031"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=44031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}