摘要:
public void SelectSort(int[] ary) { // 需要遍历获得最小值的次数 for (int i = 0; i < ary.Length - 1; i++) { int temp = 0; int index = i; // 用来保存最小值得索引 //在后面的序列中,寻找
阅读全文
posted @ 2017-06-03 09:38
Sempron2800+
阅读(206)
推荐(0)
摘要:
https://leetcode.com/problems/array-nesting/#/description
阅读全文
posted @ 2017-06-02 11:14
Sempron2800+
阅读(124)
推荐(0)
摘要:
https://leetcode.com/problems/range-addition-ii/#/description
阅读全文
posted @ 2017-06-01 11:09
Sempron2800+
阅读(104)
推荐(0)
摘要:
https://leetcode.com/problems/minimum-index-sum-of-two-lists/#/description
阅读全文
posted @ 2017-06-01 08:56
Sempron2800+
阅读(132)
推荐(0)
摘要:
快速排序的效率比较高的算法,如果我们只能掌握一种排序,那快速排序是最佳的选择。 private int Division(int[] list, int left, int right) { // 以最左边的数(left)为基准 int bs = list[left]; while (left <
阅读全文
posted @ 2017-05-31 08:17
Sempron2800+
阅读(155)
推荐(0)
摘要:
冒泡排序是,最长用的一种排序方式。它效率虽然不是很高,但是思路简单。 public void BubbleSort(int[] a) { int i, j; var n = a.Length; for (i = n - 1; i > 0; i--) { // 将a[0...i]中最大的数据放在末尾
阅读全文
posted @ 2017-05-31 08:10
Sempron2800+
阅读(183)
推荐(0)
摘要:
希尔排序又称缩小增量排序,这种排序方法先将整体的无序序列进行分组,设定每个组的大小为分组因子dk。分完组后,第i个和第i+dk个,i+2dk个,i+3dk个...元素为一个组。然后对这个组进行某种方式的排序,可以使用插入排序。 对每个组排完序之后,得到一个“有序程度”好一些的序列。然后缩小分组因子d
阅读全文
posted @ 2017-05-29 09:46
Sempron2800+
阅读(197)
推荐(0)
摘要:
public void Merge(int[] a, int start, int mid, int end) { int[] tmp = new int[end - start + 1]; // tmp是汇总2个有序区的临时区域 int i = start; // 第1个有序区的索引 int j
阅读全文
posted @ 2017-05-28 11:55
Sempron2800+
阅读(163)
推荐(0)
摘要:
折半插入与直接插入的不同在于,搜索要插入的位置的时候,使用的是折半搜索(二分搜索)。这种查找方式理论上比顺序查找的效率要高。 其代码实现如下: public IList<int> InsertionSort(int[] ary) { for (int i = 1; i < ary.Length; i
阅读全文
posted @ 2017-05-27 13:41
Sempron2800+
阅读(190)
推荐(0)
摘要:
直接插入排序的一种实现: public IList<int> InsertionSort(int[] ary) { var len = ary.Length; for (int i = 1; i < len; i++) { var key = ary[i]; for (int j = 0; j <
阅读全文
posted @ 2017-05-27 11:11
Sempron2800+
阅读(293)
推荐(0)