码迷,mamicode.com
首页 >  
搜索关键字:radix sort    ( 13156个结果)
hdoj 1863 畅通工程 【最小生成树】+【kruskal】
题意:。。。 难点:如何判断是不是信息不全:在输入的时候建立并查集,之后判断有几个节点就可以了,剩下的就是kruskal算法。 代码: #include #include #include #define MAXN 105 #define INF 0x3f3f3f3f using std::sort; struct node{ int from; int to; int w; }ed...
分类:其他好文   时间:2014-08-12 22:09:14    阅读次数:257
java快速排序
//快速排序思想:选择数组最后一个数(key),比它小的排他前面 ( key放中间 ) 比它大的排后面, 然后递归 终止条件(数组只有一个数) public class Sort> { //能排序的都是能比较的,所以必须继承java.lang.Comparable public void quick(T[] array){ sort(array,0,array.length...
分类:编程语言   时间:2014-08-12 18:59:34    阅读次数:181
【HackerRank】Insertion Sort Advanced Analysis(归并排序求数列逆序数对)
Insertion Sort is a simple sorting technique which was covered in previous challenges. Sometimes, arrays may be too large for us to wait around for in...
分类:其他好文   时间:2014-08-12 18:13:14    阅读次数:404
python冒泡排序
def bubble_sort(list):     for i in range(len(list)):         for j in (range(i,len(list))):             if list[j]                 temp = list[j]                 list[j] = list[i]...
分类:编程语言   时间:2014-08-12 17:27:54    阅读次数:216
python选择排序
def select_sort(list): for i in range(len(list)): position = i for j in range(i,len(list)): if list[position] > list[j]: position = j temp = list[i] list[i] = list[position] list[pos...
分类:编程语言   时间:2014-08-12 17:25:34    阅读次数:236
python插入排序
def insert_sort(list): for i in range(len(list)): while i > 0 and list[i] < list[i-1]: temp = list[i] list[i] = list[i-1] list[i-1] = temp i = i-1...
分类:编程语言   时间:2014-08-12 17:25:24    阅读次数:269
c#中list sort排序
1、List.Sort(泛型Comparison)法此方法的参数是Comparison类型,其实是一个包含两个参数的委托,因此使用此方法,我们只需要定义一个委托,其两个参数均为Student类型,在委托实现的方法比较两个Student对象的Age属性即可。 usingSystem; usingSystem.Collections.Generic; usi..
分类:其他好文   时间:2014-08-12 13:51:55    阅读次数:229
LeetCode:Sort List
Problem:       Sort a linked list in O(n log n) time using constant space complexity. 解题思路:     首先,时间复杂度能达到O(nlgn)的排序算法,常见的有3种:堆排序、归并排序和快速排序, 而对于链表,用堆排序显然不太可能,所以,我们可用归并或者是快排.由于合并...
分类:其他好文   时间:2014-08-12 00:45:13    阅读次数:217
将n进制的数组压缩成字符串(0-9 a-z)同时解压
此类题目要明确两点: 1. 打表:用数组下标索引字符,同时注意如果从字符对应回数字:  int index = (str[i] >= '0' && str[i] 2. 注意低位在前还是高位在前,如果先来的是 低位*radix^i 即可。 3. 统计每几个radix进制数组成一位,利用bits来表示。。。 这破题主要是麻烦。。。 #include #includ...
分类:其他好文   时间:2014-08-12 00:40:33    阅读次数:184
[leetcode]Sort Colors
Sort ColorsGiven an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the or...
分类:其他好文   时间:2014-08-12 00:09:03    阅读次数:154
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!