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
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
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
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
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