![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序
文章平均质量分 66
kingbird_Wang
努力奋斗中...
展开
-
排序算法 - 基数排序(C++)
/* * Get the spcific digit of given number. * For example, number 234, * the 0st digit is 4, * the 1st digit is 3, * the 2nd digit is 2, * the 3th digit is 0. */int GetNDigit(int nNumber, i原创 2012-04-07 15:36:25 · 6577 阅读 · 1 评论 -
排序算法 - 快速排序(C++)
// 单向扫描就地重排int Partitation_1Way(int array[], int nIdxLeft, int nIdxRight){ assert(NULL != array); if (nIdxLeft == nIdxRight) return nIdxLeft; // Take the last element as middle value. int nM原创 2012-04-07 11:21:59 · 528 阅读 · 0 评论 -
排序算法 - 计数排序(C++)
/*************************************************** * array: * array that to be sorted. * nLength: * length of array * nK: * 可能出现的最大数字(对10进制数排序则nK=9).******************************************原创 2012-04-07 15:25:12 · 934 阅读 · 0 评论 -
两个已排序数组的归并
Cracking the coding interview 9.1You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order.思路:从后向前归并。这里有个问题需要原创 2013-01-06 16:37:22 · 1229 阅读 · 0 评论 -
排序算法 - 堆排序 (C++)
堆排序的基本过程:1. 找到最大的元素,放到最后面去2. 找到第二大的元素,放在倒数第二个位置。。。依次类推,直到所有元素完成排序。其中每一步中,找最大元素的方法是借助堆。堆可以看成是一个完全二叉树,且每个节点的值都大于它的子节点的值。对于数组来说,就是任意第[i]个元素大于第[2i+1]和第[2i+2]个元素。为了将无序数组变成堆,需要从叶到根依次建堆。也就是从 从后往前第一个有原创 2012-04-06 18:04:46 · 607 阅读 · 0 评论