插入排序适合数据大多数已经排好序的情况,时间复杂度为O(n*n)。#include using namespace std;int a[200]={3,354,12,54,897,1000,1};void insert_sort(int n){ int j; int temp; f...
分类:
其他好文 时间:
2014-09-20 16:33:28
阅读次数:
148
快排用到了分治思想和递归思想。效率不稳定,平均复杂度在维持在O(n*logn),可见,在n较大时应用较好。#include using namespace std;int a[200] = {564,321,1,2,3,654,21};void quick_sort(int left,int rig...
分类:
其他好文 时间:
2014-09-20 15:27:48
阅读次数:
194
sort()一般用于 对象 数组或者List类(Set不可)排序,需要类实现Comparable接口void static sort(List list)根据元素的自然顺序 对指定列表按升序进行排序是属于Collections类的一个静态方法,也就是说可以这样调用:int[] a={.....}; ...
分类:
其他好文 时间:
2014-09-20 14:32:08
阅读次数:
198
List.sort()可以实现对T的排序,比如List.sort()执行后集合会按照int从小到大排序。如果T是一个自定义的Object,可是我们想按照自己的方式来排序,那该怎么办呢,其实可以用过IComparable接口重写CompareTo方法来实现。流程如下:一.第一步我们申明一个类Pers....
分类:
其他好文 时间:
2014-09-20 02:14:36
阅读次数:
291
Collection of algorithm for sorting
heap sort 堆排序
The heapsort algorithm can be divided into two parts.
In the first step, a heap is built out
of the data. The h...
分类:
其他好文 时间:
2014-09-19 19:24:45
阅读次数:
220
input:a finite set of two dimentional points P (the number of points n is more than 2)output: the convex hull of PPesudo:1, sort P in Lexgrahical orde...
分类:
其他好文 时间:
2014-09-19 15:25:35
阅读次数:
230
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, ...
分类:
其他好文 时间:
2014-09-19 13:43:05
阅读次数:
194
linux之sort用法sort命令是帮我们依据不同的数据类型进行排序,其语法及常用参数格式: sort [-bcfMnrtk][源文件][-o 输出文件]补充说明:sort可针对文本文件的内容,以行为单位来排序。参 数:-b忽略每行前面开始出的空格字符。-c检查文件是否已经按照顺序排序。-f排.....
分类:
系统相关 时间:
2014-09-19 11:50:55
阅读次数:
221