【题目】
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
议题:快速排序实现之一(单向遍历)分析:算法原理:主要由两部分组成,一部分是递归部分QuickSort,它将调用partition进行划分,并取得划分元素P,然后分别对P之前的部分和P
之后的部分递归调用QuickSort;另一部分是partition,选取划分元素P(随机选取数组中的一个元素,交换...
分类:
其他好文 时间:
2014-06-03 10:00:23
阅读次数:
392
议题:快速排序实现之五(非递归实现,短序列优先处理,减少递归栈大小)分析:算法原理:此算法实现适用于系统栈空间不足够快速排序递归调用的需求,从而使用非递归实现快速排序算法;使用显示下推栈存储快速排序中的每一次划分结果
(将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
本文转载自:http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html简介awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大。简单来说awk就是把文件逐行的读入,以空...
分类:
系统相关 时间:
2014-05-31 11:39:49
阅读次数:
543
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
Sort a linked list using insertion sort./** *
Definition for singly-linked list. * struct ListNode { * int val; * ListNode
*next; * ListNo...
分类:
其他好文 时间:
2014-05-30 15:14:27
阅读次数:
245