摘要: Scientists jump to the rescue with some distinctly shaky evidence to the effect that insects would eat us up if birds failed to control them.(2010, 46 阅读全文
posted @ 2019-04-19 23:03 sqdtss 阅读(138) 评论(0) 推荐(0) 编辑
摘要: Television is one of the means by which these feelings are created and conveyed——and perhaps never before has it served so much to connect different p 阅读全文
posted @ 2019-04-19 22:58 sqdtss 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Dawin was conviced that the loss of these tastes was not only a loss of hapiness,but might possibly be injurious to the intellect, and more probably t 阅读全文
posted @ 2019-04-19 22:49 sqdtss 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1 //问题描述: 试编写一个算法,使之能够在数组L[1...n]中找出第k小的元素(即从小到大排序后处于第k个位置的元素) 2 3 #include 4 5 // 结合快排思想,查找第5小函数 6 int find_the_minist_k(int sz[], int k, int low, int high) 7 { 8 int lowtemp = low, h... 阅读全文
posted @ 2019-04-19 22:12 sqdtss 阅读(656) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 5 // 简单选择排序 6 void select_sort(int sz[], int len) 7 { 8 for (int i = 0; i < len; i++) 9 { 10 // 选择出剩余为排序子数组中最小(大)值,加到已排序子数组中... 阅读全文
posted @ 2019-04-19 21:24 sqdtss 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 /** 4 * 快速排序因为是递归的,需要借助一个递归工作栈来保存每层递归调用的必要信息,其容量与递归调用的最大深度一致。 5 * 最好情况下为[log2(n+1)](上取整), 最坏情况下因为要进行n-1次递归调用,所以栈的深度为O(n),平均情况下栈的深度为O(log2n) 6 * 快速排序的平均时间复杂度为O(nlog2n),最坏情况下为... 阅读全文
posted @ 2019-04-19 21:17 sqdtss 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include // 希尔排序 void shell_sort(int sz[], int len) { // 对顺序表做希尔排序,本算法和直接插入排序相比,做了一下修改: //1.前后记录位置的增量是dk,不是1 //2.sz[0]只是暂存单元,不是哨兵 //3.希尔排序是不稳定的排序(当相同的关键字被划分到不同的子表中时,可能会改变他们的相对次序) ... 阅读全文
posted @ 2019-04-19 20:47 sqdtss 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 设有一个仅由红、白、蓝三种颜色的条块组成的条块序列,请编写一个时间复杂度为O(n)的算法,使得这些条块按红、白、蓝的顺序排好,即排成荷兰国旗图案。 1 #include 2 #include 3 using namespace std; 4 5 typedef enum 6 { 7 RED, 8 WHITE, 9 BLUE 10 } color; /... 阅读全文
posted @ 2019-04-19 20:23 sqdtss 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 // 直接插入排序 4 void insert_sort(int sz[], int len) 5 { 6 for (int i = 2; i sz[0]; j--) 15 { 16 sz[j + 1] = sz[j]; 17 } 18 ... 阅读全文
posted @ 2019-04-19 19:39 sqdtss 阅读(220) 评论(0) 推荐(0) 编辑