码迷,mamicode.com
首页 >  
搜索关键字:sort    ( 12890个结果
排序算法之stooge排序
stooge排序是一种递归排序算法,这种排序算法不仅慢于一般的有效排序算法(如:插入排序,合并排序,堆排序和快速排序),甚至慢于冒泡排序。是一种简单但低效的排序算法。...
分类:其他好文   时间:2014-06-07 01:26:17    阅读次数:173
LeetCode: Sort Colors [075]
【题目】 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, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and...
分类:其他好文   时间:2014-06-07 01:17:49    阅读次数:269
Iterative (non-recursive) Merge Sort
An iterative way of writing merge sort: #include using namespace std; void merge(int A[], int l, int r, int e, int B[]) { int i = l, j = r, k = l; while (i<r && j A[j]) B[k++] =...
分类:其他好文   时间:2014-06-03 02:33:24    阅读次数:215
Iterative (non-recursive) Quick Sort
An iterative way of writing quick sort: #include #include #include using namespace std; void quickSort(int A[], int n) { stack> stk; stk.push(make_pair(0, n-1)); while (!stk.empty()) { pair ...
分类:其他好文   时间:2014-06-03 00:16:43    阅读次数:357
使用函数指针,完成一个sort()函数,能对任何类型的数组元素进行排序: 回调函数 以及 memcpy ()原型实现
进来复习了一下C语言指针,一直没有写过太多关于函数指针的代码,而且对回调函数的理解一直都是在理论上,基本上没有太写过关于它的代码,进来得空,写了一个小程序加深下自己对回调函数和函数指针的理解。 问题描述: 编写一个sort()函数,使它能够对任何类型的数组元素进行排序。 下面是我写的代码: /* 使用函数指针的回调函数技巧,设计一个能排序int 和char 数组的sort()函...
分类:其他好文   时间:2014-06-02 23:16:49    阅读次数:471
【LeetCode】Sort List
Sort ListSort a linked list inO(nlogn) time using constant space complexity.要求时间复杂度为O(nlogn),那么不能用quickSort了(最坏O(n^2)),所以使用mergeSort.通常写排序算法都是基于数组的,这题...
分类:其他好文   时间:2014-06-02 06:29:51    阅读次数:192
javascript数组常用方法
<!DOCTYPEhtml> <html> <headlang="en"> <metacharset="UTF-8"> <title>数组</title> <scripttype="text/javascript"> vara1=[1,4,5,7,8]; vara2=newArray(‘b‘,‘a‘,‘d‘); a1.sort(function(i,j){ returni-j; }); a2.sort(); consol..
分类:编程语言   时间:2014-06-02 04:05:42    阅读次数:354
LeetCode Sort Colors
class Solution { public: void swap(int &a,int &b) { int t=a; a=b; b=t; } void ksort(int l,int h,int a[]) { if(h<l+2) return; int e=h,p=l; while(...
分类:其他好文   时间:2014-06-02 03:01:26    阅读次数:206
怎样对ListView的项进行排序
当您使用资源浏览器查看文件时,您能够随心所欲的按名称、大小、类型及改动日期不同的列对文件进行大小排序。.Net提供的ListView组件没有直接提供这样的功能,但要实现并不难。 ListView.Sort()方法的功能是“对列表视...
分类:其他好文   时间:2014-06-02 00:03:13    阅读次数:241
Java接口
接口是一组对类的需求描述,这些类要遵从接口描述的统一格式进行定义。 “如果你的类遵从某个特定接口,那么我就履行这项服务”。 一个具体的例子:Arrays类中的sort方法承诺可以对对象数组进行排序,但要求满足一个前提:对象所属的类必须实现了Comparable接口。 如: class Employee implements Comparable{ private doubl...
分类:编程语言   时间:2014-06-01 15:42:18    阅读次数:349
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!