当前位置: 首页 > news >正文

做亚马逊需要的图片外链网站深圳网站建设制作设计平台

做亚马逊需要的图片外链网站,深圳网站建设制作设计平台,做企业网站需要什么,江西中慧城乡建设开发公司网站棋牌类游戏算法–牌分类毫无疑问#xff0c;Quicksort被认为是本世纪最重要的算法之一#xff0c;并且它是许多语言的事实上的系统排序#xff0c;包括Java中的Arrays.sort 。 那么#xff0c;quicksort有何新功能#xff1f; 好吧#xff0c;除了我刚刚#xff08;在J… 棋牌类游戏算法–牌分类 毫无疑问Quicksort被认为是本世纪最重要的算法之一并且它是许多语言的事实上的系统排序包括Java中的Arrays.sort 。 那么quicksort有何新功能 好吧除了我刚刚在Java 7发行了2年之久之后才想到 Arrays.sort的Quicksort实现已被称为Dual-Pivot QuickSort的变体替代。 出于这个原因这个线程很棒而且乔恩·本特利和约书亚·布洛赫真的很谦虚。 接下来我要做什么 就像其他所有人一样我也想实现它并针对约1000万个整数随机和重复进行一些基准测试。 奇怪的是我发现以下结果 随机数据 快速排序基本1222毫秒 快速排序3种方式1295毫秒严重 双轴快速排序1066毫秒 重复数据 快速排序基础378毫秒 快速排序3种方式15毫秒 快速分类双枢轴6毫秒 愚蠢的问题1 恐怕在三向分区的实现中缺少一些东西。 在针对随机输入1000万个的数字进行的多次运行中我可以看到单个枢轴始终表现更好尽管对于1000万个数字其差异小于100毫秒。 我知道直到现在将三路Quicksort设置为默认Quicksort的全部目的是它不会在重复键上提供0n 2性能-当我对重复输入运行它时这是非常明显的。 但是为了处理重复的数据三路方式会付出一点代价吗 还是我的实现不好 愚蠢的问题2 我的Dual Pivot实现下面的链接不能很好地处理重复项。 它需要永远的甜蜜0n 2才能执行。 有避免这种情况的好方法吗 谈到Arrays.sort实现我发现在完成实际排序之前就消除了升序和重复项。 因此作为一个肮脏的解决方法如果枢轴相等则我快进lowerIndex直到它与pivot2不同。 这是公平的实施吗 else if (pivot1pivot2){while (pivot1pivot2 lowIndexhighIndex){lowIndex;pivot1input[lowIndex];}} 而已。 那就是我所做的一切 我总是发现算法的跟踪很有趣但是由于Dual Pivot quicksort中的变量数量众多我的眼睛在调试时发现它不知所措。 因此我还继续创建了启用跟踪的实现针对所有3种实现以便可以看到变量指针当前所在的位置。 这些启用了跟踪的类仅覆盖指针在数组值下方的位置。 我希望您发现这些课程有用。 例如。 用于Dual Pivot迭代 整个项目以及DSA的一些la脚实现可在github 此处获得 。 仅在这里可以找到 quicksort类。 这是我对SinglePivotHoare3waySedgewick和新Dual-PivotYaroslavskiy的实现 单枢轴 package basics.sorting.quick;import static basics.sorting.utils.SortUtils.exchange; import static basics.sorting.utils.SortUtils.less; import basics.shuffle.KnuthShuffle;public class QuickSortBasic {public void sort (int[] input){//KnuthShuffle.shuffle(input);sort (input, 0, input.length-1);}private void sort(int[] input, int lowIndex, int highIndex) {if (highIndexlowIndex){return;}int partIndexpartition (input, lowIndex, highIndex);sort (input, lowIndex, partIndex-1);sort (input, partIndex1, highIndex);}private int partition(int[] input, int lowIndex, int highIndex) {int ilowIndex;int pivotIndexlowIndex;int jhighIndex1;while (true){while (less(input[i], input[pivotIndex])){if (ihighIndex) break;}while (less (input[pivotIndex], input[--j])){if (jlowIndex) break;}if (ij) break;exchange(input, i, j);}exchange(input, pivotIndex, j);return j;}} 3路 package basics.sorting.quick;import static basics.shuffle.KnuthShuffle.shuffle; import static basics.sorting.utils.SortUtils.exchange; import static basics.sorting.utils.SortUtils.less;public class QuickSort3Way {public void sort (int[] input){//inputshuffle(input);sort (input, 0, input.length-1);}public void sort(int[] input, int lowIndex, int highIndex) {if (highIndexlowIndex) return;int ltlowIndex;int gthighIndex;int ilowIndex1;int pivotIndexlowIndex;int pivotValueinput[pivotIndex];while (igt){if (less(input[i],pivotValue)){exchange(input, i, lt);}else if (less (pivotValue, input[i])){exchange(input, i, gt--);}else{i;}}sort (input, lowIndex, lt-1);sort (input, gt1, highIndex);}} 双枢轴 package basics.sorting.quick;import static basics.shuffle.KnuthShuffle.shuffle; import static basics.sorting.utils.SortUtils.exchange; import static basics.sorting.utils.SortUtils.less;public class QuickSortDualPivot {public void sort (int[] input){//inputshuffle(input);sort (input, 0, input.length-1);}private void sort(int[] input, int lowIndex, int highIndex) {if (highIndexlowIndex) return;int pivot1input[lowIndex];int pivot2input[highIndex];if (pivot1pivot2){exchange(input, lowIndex, highIndex);pivot1input[lowIndex];pivot2input[highIndex];//sort(input, lowIndex, highIndex);}else if (pivot1pivot2){while (pivot1pivot2 lowIndexhighIndex){lowIndex;pivot1input[lowIndex];}}int ilowIndex1;int ltlowIndex1;int gthighIndex-1;while (igt){if (less(input[i], pivot1)){exchange(input, i, lt);}else if (less(pivot2, input[i])){exchange(input, i, gt--);}else{i;}}exchange(input, lowIndex, --lt);exchange(input, highIndex, gt);sort(input, lowIndex, lt-1);sort (input, lt1, gt-1);sort(input, gt1, highIndex);}} 参考 Resort.me博客上的快速排序–我们JCG合作伙伴 Arun Manivannan的3向和双向旋转 。 翻译自: https://www.javacodegeeks.com/2013/06/quicksorting-3-way-and-dual-pivot.html棋牌类游戏算法–牌分类
http://www.zqtcl.cn/news/112077/

相关文章:

  • 海淘网站是谁做的为该网站做自适应
  • php网站开发自学如何做x响应式网站
  • 吴忠网站建设公司随州网站建设优化推广渠道
  • dedecms 招聘网站网站建设市场调研报告
  • 建小网站多少钱做会计网站的流程
  • 为一个村做网站优秀文创产品设计案例及分析
  • 山东专业网站建设公司哪家好网站开发的薪资是多少
  • 无极在线网站播放烟台注册公司
  • 网站源文件修改科技网站欣赏
  • 关于h5的网站目录 首页 wordpress
  • 包头网站建设推广手机网站开发介绍
  • 网站推广设计用那种语言做网站比较好
  • 手机品牌网站如何做好网站内更新
  • 订餐网站模板下载毕业设计动漫网页设计
  • 网站阵地建设管理办法移动端网页界面设计
  • 网站和做游戏重庆市建设工程信息网安全监督特种人员
  • 沈阳网站建设活动方案部分网站打不开的原因
  • 网站维护界面设计做的网站一直刷新
  • 国外网站 国内访问速度土木工程毕业设计网站
  • 宿迁网站建设制作中国广告设计网
  • 上门做美容的有什么网站微信网页版本
  • 专门做餐饮运营的网站网站开发相关知识
  • 石家庄门户网站建设免费简历模板的网站
  • 微网站建设市场如何做好平台推广
  • 网站不备案做优化小程序开发前景怎么样
  • 美丽说网站优化百度关键词优化
  • 同性男做的视频网站赶集网招聘最新招聘附近找工作
  • 做挖机配件销售的网站oa办公系统软件哪家好
  • 聊城设计网站商务网站的特点
  • 厦门做个网站多少钱工程建设范围