介绍给大家一个快速排序的方法:
void sort(int a[ ], int l, int r)
{
int i = l;
int j = r;
int mid = a[(i+j)/2];
do
{
while(a[i]
while(a[j] >mid ) j--;
if( i
{
swap( a[i], a[j] );
}...
分类:
编程语言 时间:
2014-06-20 13:15:03
阅读次数:
292
数据结构 - 简单选择排序(simple selection sort)本文地址: http://blog.csdn.net/caroline_wendy/article/details/28601965 选择排序(selection sort) : 每一趟在n-i+1个记录中选取关键字最小的记录作为有序序列中第i个记录.简单选择排序(simple selection sort) : 通过n-i次关键字之间的比较, 从n-i+1个记录中选出关键字最...
分类:
编程语言 时间:
2014-06-20 09:48:25
阅读次数:
332
题目链接: here。题目描述: Sort a linked list using insertion
sort. 题目要求使用插入排序的方法来实现单链表的排序。插入排序是一种简单的排序,算法描述参考维基百科,或者《算法导论》。 下面是我实现的代码: 1 /**
2 Author:...
分类:
其他好文 时间:
2014-06-12 00:39:40
阅读次数:
284
count(*)是否能用到索引,用索引是高效还是低效select count(*) from
aa ;首先看是否会走索引,经过试验发现,他没有走索引它的执行计划 select statement sort aggregate table access
full别说是否高效了,他连索引都没有走,索引不...
分类:
其他好文 时间:
2014-06-11 12:00:01
阅读次数:
282
集合框架的工具类:collecttionsCollections 的方法全是静态的
List没有排序功能,所以java定义了Collections工具类。 比较器无法传给list,只能传给Set.但是集合工具类有此方法1.排序:
comparable: sort(List list) 根据元素的自然...
分类:
其他好文 时间:
2014-06-11 08:54:10
阅读次数:
218
类的适配器模式classCIntegerSortAdapter:DoubleSort,Sortable{publicint[]Sort(int[]number){double[]dnum=newdouble[number.Length];int[]inum=newint[number.Length]...
分类:
其他好文 时间:
2014-06-11 08:04:50
阅读次数:
242
众所周知,Std::sort()是一个非常快速的排序算法,它基于快排,但又有所修改。一般来说用它就挺快的了,代码一行,时间复杂度O(nlogn)(难道不是大叫一声“老子要排序!!”就排好了么。。。)。我们也知道,不基于比较的排序可以达到O(n),比如说基数排序。什么,它是O(n
* log(10.....
分类:
其他好文 时间:
2014-06-10 00:04:07
阅读次数:
326
排序算法是我们工作中使用最普遍的算法,常见的语言库中基本都会有排序算法的实现,比如c标准库的qsort,stl的sort函数等。本文首先介绍直接插入排序,归并排序,堆排序,快速排序和基数排序等比较排序算法,然后介绍计数排序,基数排序等具有线性时间的排序算法。本文主要讨论算法的实现方法,并不会过多介绍...
分类:
其他好文 时间:
2014-06-07 21:23:31
阅读次数:
348
原文:浅谈算法和数据结构: 四
快速排序上篇文章介绍了时间复杂度为O(nlgn)的合并排序,本篇文章介绍时间复杂度同样为O(nlgn)但是排序速度比合并排序更快的快速排序(Quick
Sort)。快速排序是20世纪科技领域的十大算法之一 ,他由C. A. R. Hoare于1960年提出的一种划分交...
分类:
其他好文 时间:
2014-06-07 20:15:43
阅读次数:
362
Given an array withnobjects colored red, white
or blue, sort them so that objects of the same color are adjacent, with the
colors in the order red, wh...
分类:
其他好文 时间:
2014-06-07 20:11:53
阅读次数:
234