abc_begin

导航

2017年10月10日 #

排序_归并排序

摘要: 核心的merge函数: 递归算法: 非递归算法: 要点: (1)为了节省空间所以两边分别倒,这在主函数里面实现 (2)注意区别奇偶区间 阅读全文

posted @ 2017-10-10 15:22 LastBattle 阅读(168) 评论(0) 推荐(0) 编辑

排序_选择排序

摘要: 1 void selectSort(LineList R[], int n) 2 { 3 int i, j, index; 4 for (i = 1; i < n; i++) 5 { 6 index = i; 7 for (j = i + 1; j <= n; j++) 8 ... 阅读全文

posted @ 2017-10-10 10:28 LastBattle 阅读(143) 评论(0) 推荐(0) 编辑

2017年10月9日 #

排序_快速排序

摘要: pivot选取3值平均 阅读全文

posted @ 2017-10-09 19:38 LastBattle 阅读(517) 评论(0) 推荐(0) 编辑

排序_冒泡排序

摘要: 上面代码效率还是比较低下的,因为有可能中间某次就有序了,但是依然多执行了很多次循环,可以改为如下算法: 稳定性:稳定 复杂度: (1)最好:O(N) (2)最坏:O(N2) 阅读全文

posted @ 2017-10-09 16:58 LastBattle 阅读(161) 评论(0) 推荐(0) 编辑

排序_希尔排序

摘要: 下标从0开始的算法如下: 另外还有sedgewick序列的方法 阅读全文

posted @ 2017-10-09 16:28 LastBattle 阅读(178) 评论(0) 推荐(0) 编辑

排序_插入排序

摘要: 下标从0开始的算法如下: 稳定性:稳定 复杂度: (1)最好:O(N) (2)最坏:O(N2) 阅读全文

posted @ 2017-10-09 14:45 LastBattle 阅读(106) 评论(0) 推荐(0) 编辑

2017年10月3日 #

121. Best Time to Buy and Sell Stock【easy】

摘要: 121. Best Time to Buy and Sell Stock【easy】 Say you have an array for which the ith element is the price of a given stock on day i. If you were only pe 阅读全文

posted @ 2017-10-03 16:27 LastBattle 阅读(317) 评论(0) 推荐(0) 编辑

167. Two Sum II - Input array is sorted【easy】

摘要: 167. Two Sum II - Input array is sorted【easy】 Given an array of integers that is already sorted in ascending order, find two numbers such that they ad 阅读全文

posted @ 2017-10-03 15:18 LastBattle 阅读(161) 评论(0) 推荐(0) 编辑

283. Move Zeroes【easy】

摘要: 283. Move Zeroes【easy】 Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero ele 阅读全文

posted @ 2017-10-03 13:06 LastBattle 阅读(290) 评论(0) 推荐(0) 编辑

561. Array Partition I【easy】

摘要: 561. Array Partition I【easy】 Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., 阅读全文

posted @ 2017-10-03 11:47 LastBattle 阅读(107) 评论(0) 推荐(0) 编辑