Loading

上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 75 下一页
摘要: 阅读全文
posted @ 2018-10-14 15:18 拾月凄辰 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 算法2: 阅读全文
posted @ 2018-10-14 15:16 拾月凄辰 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 1、最大堆的定义及其常用操作: 2、函数实现: 3、最大堆的建立 目的:将已经存在的N个元素按照最大堆的要求存放在一个一维数组中。 方法1:通过插入操作,将N个元素一个个相继插入到一个初始为空的堆中去,其时间代价最大为O(NlogN)。 方法2:在线性时间复杂度O(N)下建立最大堆。 (1) 将N个 阅读全文
posted @ 2018-10-14 11:01 拾月凄辰 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 选主元 1、选择最左边的第一个元素为主元(普通版快速排序) 假设我们现在对“6 1 2 7 9 3 4 5 10 8”这个10个数进行排序。首先在这个序列中随便找一个数作为基准数。为了方便,就让第一个数6作为基准数吧。接下来,需要将这个序列中所有比基准数大的数放在6的右边,比基准数小的数放在6的左边 阅读全文
posted @ 2018-10-13 10:53 拾月凄辰 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度: 注意: 在MergeSort中定义TmpA临时数组,可以使整个过程只申请释放空间一次,空间复杂度为O(N) ,如果在Merge函数里定义TmpA数组的话,整个过程将反复malloc与free,使得空间复杂度变为O( NlogN)。 阅读全文
posted @ 2018-10-13 10:45 拾月凄辰 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 1 //插入排序 2 void InsertionSort(ElementType A[], int N) 3 { 4 int p, i, tmp; 5 for(p = 1; p = 1) 10 { 11 if(A[i-1] > tmp) 12 A[i] = A[i-1]; //... 阅读全文
posted @ 2018-10-08 21:42 拾月凄辰 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 1 void Swap(ElementType *a, ElementType *b) 2 { 3 ElementType tmp = *a; 4 *a = *b; 5 *b = tmp; 6 } 7 8 //选择排序 9 void SelectionSort(ElementType A[], int N) 10 { 11 for(in... 阅读全文
posted @ 2018-10-08 20:24 拾月凄辰 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 1 void Swap(ElementType *a, ElementType *b) 2 { 3 ElementType tmp = *a; 4 *a = *b; 5 *b = tmp; 6 } 7 8 //冒泡排序 9 void BubbleSort(ElementType A[], int N) 10 { 11 for(in... 阅读全文
posted @ 2018-10-08 19:58 拾月凄辰 阅读(119) 评论(0) 推荐(0) 编辑
摘要: After they became famous, the CodeBots all decided to move to a new building and live together. The building is represented by a rectangular matrix of 阅读全文
posted @ 2018-10-07 13:13 拾月凄辰 阅读(731) 评论(0) 推荐(0) 编辑
摘要: 转载自:https://blog.csdn.net/yilovexing/article/details/80576788 序列解包是 Python 3.0 之后才有的语法 什么是序列解包呢?先看一个例子: 这种方法并不限于列表和元组,而是适用于任意序列类型(甚至包括字符串和字节序列)。只要赋值运算 阅读全文
posted @ 2018-10-06 10:23 拾月凄辰 阅读(529) 评论(0) 推荐(0) 编辑
上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 75 下一页