今天工作室断网!果断回宿舍,不然各种资料都没有.(他说将来会找到!)不好意思,又哼起来了.进入主题,大家都知道,快排是各种排序算法中,最高效的也是应用最广的,还有更重要的一点,面试特别爱考的! 其实大家或多或少都听说过快排,也就是先从取出一个基准值,然后再把其它的数与之相对比,小的放左边的集合里,大的放右边的集合里,再通过递归不断重复该步骤,实现最高效率的quickSort. Talk is cheap, show you my code!…
Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, whit…
啥是快排这里就不讲了,主要还是把原来c++学的东西抓紧转化过来 快排运用的是分而治之的思想,确定一个中值,把大的放右边,小的放左边,然后再左右分别对左右的左右(雾)进行处理 需要注意的一点是,这玩意远没有sort函数跑的快 function quickSort(arr){ if(arr.length <= 1){ return arr; } let l = [], r = []; let mid = Math.round(arr.length / 2); for(let i = 0; i <…