stooge排序是一种递归排序算法,这种排序算法不仅慢于一般的有效排序算法(如:插入排序,合并排序,堆排序和快速排序),甚至慢于冒泡排序。是一种简单但低效的排序算法。...
分类:
其他好文 时间:
2014-06-07 01:26:17
阅读次数:
173
【题目】
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
冒泡排序法是一种经典的、入门级的排序算法。它重复地遍历整个数组,对数组的元素进行两两比较,如果两数的顺序有误,则将两数字交换。
由于在比较的过程中,最小的数先变换到数列的顶端,其次是第二小的数……直至所有数字完成排序,因而得名冒泡排序。...
分类:
其他好文 时间:
2014-06-05 11:39:09
阅读次数:
194
延迟标记像极了线段书,不再多说。
区间反转在树伸展到位之后,也变成了简单的递归交换左右儿子。
愈发感觉到伸展树简直太漂亮了,伸展操作更是诱惑到不行 ,总之数据结构太有魅力了。
比较简单,就直接上模板了。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#pr...
分类:
其他好文 时间:
2014-06-05 08:33:14
阅读次数:
190
议题:快速排序实现之五(非递归实现,短序列优先处理,减少递归栈大小)分析:算法原理:此算法实现适用于系统栈空间不足够快速排序递归调用的需求,从而使用非递归实现快速排序算法;使用显示下推栈存储快速排序中的每一次划分结果
(将left和right都压入堆栈),并且首先处理划分序列较短的子序列(也就是在得...
分类:
其他好文 时间:
2014-06-03 08:23:29
阅读次数:
367
quick sort of array and linked list
分类:
其他好文 时间:
2014-06-03 08:16:22
阅读次数:
359
可以使用一下命令查使用内存最多的5个进程ps -aux | sort -k4nr | head
-n 5或者top (然后按下M,注意大写)可以使用一下命令查使用CPU最多的5个进程ps -aux | sort -k3nr | head -n 5或者top
(然后按下P,注意大写)
分类:
系统相关 时间:
2014-06-03 07:30:14
阅读次数:
301
1 如何将字串 String 转换成整数 int?
A. 有两个方法:
1). int i = Integer.parseInt([String]); 或
i = Integer.parseInt([String],[int radix]);
2). int i = Integer.valueOf(my_str).intValue();
注: 字串转成 Double, Float, Lo...
分类:
编程语言 时间:
2014-06-03 04:43:07
阅读次数:
297
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
DescriptionYou have an
arraya[1],?a[2],?...,?a[n], containing distinct integers from1ton. Your task is
to sort this array in increasing order with the...
分类:
其他好文 时间:
2014-05-31 01:35:23
阅读次数:
318