码迷,mamicode.com
首页 >  
搜索关键字:sort    ( 12890个结果
关于插入排序的实现
插入排序是排序算法中一个常见的算法,个人觉得插入排序和冒泡排序有很大的相同之处。先看两段代码:1、来自http://www.cnblogs.com/xkfz007/archive/2012/07/01/2572017.htmlvoid insert_sort(int a[],int n){ _...
分类:编程语言   时间:2015-03-08 18:42:25    阅读次数:126
堆排序
从大到小排序,小根堆。小根堆的筛选算法:void sift(int data[], int k, int m) { int i = k ,int j = 2 * k; while (j <= m) { if (j data[j + 1]) ++j; if (data[i] < data[j]) break;...
分类:编程语言   时间:2015-03-08 17:18:12    阅读次数:184
快速排序
本文选择第一个元素作为轴值,从小到达排序。快速排序算法的一趟排序如下:int Partion (int data[], int first, int end) { int i = first, j = end; int privot = data[i]; while (i < j) { while (i privot) --j...
分类:编程语言   时间:2015-03-08 17:15:35    阅读次数:122
冒泡排序
基本冒泡排序冒泡排序是最常见的交换排列。void BubbleSort0 (int data[], int n) // index[1, n] { for (int i = 1; i < n; ++i) { for (int j = 1; j data[j + 1]) {...
分类:编程语言   时间:2015-03-08 15:45:25    阅读次数:141
URAL 1100. Final Standings (排序)
1100. Final Standings Time limit: 1.0 second Memory limit: 16 MB Old contest software uses bubble sort for generating final standings. But now, there are too many teams and that software ...
分类:编程语言   时间:2015-03-08 13:02:22    阅读次数:187
排序算法
#ifndef SORT_H__#define SORT_H__#include namespace Niuzb{ namespace Algorithm { template void Swap(T& lhs,T& rhs) { T tmp(lhs); lhs = rhs; rh...
分类:编程语言   时间:2015-03-08 11:41:52    阅读次数:169
【Java】Collections中sort方法Comparator的重写
很多人只会用Collections中不带比较器Comparator的sort方法完成一些对存储整形Integer的动态数组ArrayList的简单排序,包括我之前,此前仅仅在《【Java】Java中的Collections类——Java中升级版的数据结构》(点击打开链接)介绍Collections中sort方法的简单用法。 igz 面对eclipse所给出的说明,根本就不知道这个sort方...
分类:编程语言   时间:2015-03-08 10:32:28    阅读次数:234
leetcode Sort Listnode
Sort a linked list inO(nlogn) time using constant space complexity.findMiddle: 将listnode 不停的拆分sort: 将拆分好的不同的sortmerge: 将sort好的,向上merge/** * Definition...
分类:其他好文   时间:2015-03-08 07:50:33    阅读次数:128
HDU5182 PM2.5
Problem DescriptionNowadays we use content of PM2.5 to discribe the quality of air. The lower content of PM2.5 one city have, the better quality of air it have. So we sort the cities according to the c...
分类:其他好文   时间:2015-03-07 22:48:39    阅读次数:274
1069. The Black Hole of Numbers
For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by takin...
分类:其他好文   时间:2015-03-07 17:11:22    阅读次数:124
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!