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-08-24 11:32:02
阅读次数:
164
import mathclass sort: def selectSort(self, L): size = len(L) for i in range(0, size): max = L[i] index = i ...
分类:
编程语言 时间:
2014-08-23 22:48:11
阅读次数:
205
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ListSort{ class Program { static void Main(s...
分类:
其他好文 时间:
2014-08-22 23:43:59
阅读次数:
233
package algorithm;
public class SortAll {
public static void main(String[] args) {
char buf[] = {'1','2','3','4','5'};
perm(buf,0,buf.length-1);
}
private static void perm(char[] buf, int sta...
分类:
编程语言 时间:
2014-08-22 17:56:39
阅读次数:
233
[root@web~]#netstat-anp|awk‘{print$6}‘|sort|uniq-c|sort-rn172ESTABLISHED59CONNECTED589SYN_RECV15STREAMSYN居然这么高,继续追查是那些ip发出的SYN:[root@tweb~]#netstat-an|grepSYN|awk‘{print$5}‘|awk-F:‘{print$1}‘|sort|uniq-c|sort-nr|more570x.x.x.x(ip就不写出了..
分类:
系统相关 时间:
2014-08-21 19:35:16
阅读次数:
305
这题前一阵子就看到了,一直没时间做,昨晚睡前想了想,要求n*log(n)以内的时间复杂度,第一时间想到的就是归并、快排和希尔排序(注:希尔排序时间为O(n^1.3),在数据量大于2的情况下小于n*log(n)),个人以为,链表的特性更适合归并,所以采用归并排序,实现的merge代码如下:publ.....
分类:
其他好文 时间:
2014-08-21 19:01:54
阅读次数:
226
冒泡排序(Bubble Sort,台湾译为:泡沫排序或气泡排序)是一种简单的排序算法。它的基本思想就是两两比较相邻记录的关键字,如果反序则交换,直到没有反序的记录为止。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 例如:初始序列3,6,4,2,11,10,5;从头开始,两两相比...
分类:
其他好文 时间:
2014-08-21 15:07:44
阅读次数:
188
Median of Two Sorted Arrays
Total Accepted: 17932 Total
Submissions: 103927My Submissions
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sort...
分类:
其他好文 时间:
2014-08-21 13:24:54
阅读次数:
206
数组的四种排序1.快速排序法Arrays.sort();用法1.sort(byte[] a) 对指定的 byte 型数组按数字升序进行排序。 sort(byte[] a, int fromIndex, int toIndex) 对指定 byte 型数组的指定范围按数字升序进行排序。 sort(...
分类:
编程语言 时间:
2014-08-21 11:21:53
阅读次数:
288
左轴演算、中轴演算、右轴演算
题目:
快速排序法(quick sort)是目前所公认最快的排序方法之一(视解题的对象而定),虽然快速排序法在最差状况下可以达O(n2),但是在多数的情况下,快速排序法的效率表现是相当不错的。
快速排序 - 算法
1、快速排序法的基本精神是在数列中找出适当的轴心,然后将数列一分为二
2、分别对左边与右边数列进行排序...
分类:
其他好文 时间:
2014-08-21 01:38:43
阅读次数:
155