算法入门(一) 排序
2016-03-23 21:15
387 查看
摘自 <Algorithms_4th> Robert Sedgewick, chapter 2 sorting
the following class illustrates the conventions that we will use
View Code
the following class illustrates the conventions that we will use
public class Quick { public static void sort(Comparable[] a) { StdRandom.shuffle(a); // Eliminate dependence on input. sort(a, 0, a.length - 1); } private static void sort(Comparable[] a, int lo, int hi) { if (hi <= lo) return; int j = partition(a, lo, hi); // Partition (see page 291). sort(a, lo, j-1); // Sort left part a[lo .. j-1]. sort(a, j+1, hi); // Sort right part a[j+1 .. hi]. } }
View Code
相关文章推荐
- Common Lisp笔记(2)
- 理解HTTP幂等性
- php的一些小笔记--数学函数
- linux系统学习
- IOS开发-OC学习-Foundation框架练习
- LeetCode Word Pattern
- linux读书笔记(5章)
- 自适应网页设计的方法
- Android TabLayout、ViewPager实现顶部和底部Tab导航 点击滑动切换Tab页面
- 可靠信号和不可靠信号的测试
- 杭电 Problem1787 GCD Again
- Nginx [error]: invalid PID number "" in "/var/run/
- 线性表相关编程题练习
- 数据库连接信息写在properties文件
- 试探算法_随机生成彩票号码
- 四则运算四
- 有时我们不需要过多的假设
- fragment坑
- 【面试笔试算法】Problem 8: 然而沼跃鱼早就看穿了一切(hiho题库)
- PAT (Advanced Level) Practise 1078 Hashing (25)