#!/bin/shname=`ls ./`for i in $name;do aaa=`find $i -type f |xargs ls -ltr|tail -1|awk -F" " '{print $6$7" "$8}'` count=`find $i -type f -exe...
分类:
其他好文 时间:
2014-11-17 10:32:59
阅读次数:
131
Sort a linked list using insertion sort.Solution: 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ...
分类:
其他好文 时间:
2014-11-17 09:11:05
阅读次数:
218
堆排序是利用堆进行排序的高效算法,其能实现O(NlogN)的排序时间复杂度,具体算法分析可以点击堆排序算法时间复杂度分析。
算法实现:
调整堆:
void sort::sink(int* a, const int root, const int end)
{
int i=root;
while(2*i +1 <= end)
{
int k = 2*i+1;
if(k+1<=e...
分类:
编程语言 时间:
2014-11-16 23:09:56
阅读次数:
447
在前面介绍的排序算法中,最快的排序算法为归并排序,但是归并排序有一个缺陷就是排序过程中需要O(N)的额外空间。本文介绍的快速排序算法时一种原地排序算法,所需的额外空间复杂度为O(1)。
算法介绍:快速排序其实一种根据需找某个元素的具体位置进行排序的方法。比如所存在如下数组
选择第一个元素5,找到5最终的位置,即5的左边的数都小于或者等于5,右边的数都大于或者等于5.
从"6"开...
分类:
编程语言 时间:
2014-11-16 23:09:45
阅读次数:
370
对于lua的table排序问题,一般的按照value值来排序,使用table.sort( needSortTable , func)即可(可以根据自己的需要重写func,否则会根据默认来:默认的情形之下,如果表内既有string,number类型,则会因为两个类型直接compare而出错,所以需要自...
分类:
编程语言 时间:
2014-11-16 20:06:01
阅读次数:
198
1. awk最基本的功能是在输入文件中按行匹配指定的字符串格式,如果匹配则将当前行复制到缓冲区进行进一步处理,但并不改变输入文件本身。awk匹配每一行(称为Record)后,使用默认或指定的分割符自动将其分割为若干段(称为Field),每一段可使用$number进行引用和访问。其中段号0对应整个Re...
分类:
其他好文 时间:
2014-11-16 18:42:27
阅读次数:
197
Sort a linked list inO(nlogn) time using constant space complexity.分析:merge sort。class Solution {public: ListNode *sortList(ListNode *head) { ...
分类:
其他好文 时间:
2014-11-16 15:51:43
阅读次数:
210
近来想学习一下python很算法,用python实现了一下快速排序:#pythondef quick_sort(array, length): if length i): if array[j]array[j]: array[j] = ar...
分类:
编程语言 时间:
2014-11-16 14:31:10
阅读次数:
202
#!/bin/bashfunctionusage{echo"use./test_net.shethXtime"echo"$1isyounetworkinterface"echo"$2isthelasttime!"echo"forexample:./test_net.sheth02"exit100}if[$#-lt2-o$#-gt2];thenusagefieth=$1time=$2old_inbw=`cat/proc/net/dev|grep$eth|awk-F‘[:]+‘‘{print$3}‘`old_ou..
分类:
系统相关 时间:
2014-11-16 02:02:18
阅读次数:
277
//选择排序void Select_Sort(int *a,int n){ int i,j,k,temp; for(i=0;ia[j]) k=j; } temp=a[i]; a[i]=a[k]; a[k]=temp; }}
分类:
编程语言 时间:
2014-11-15 23:04:42
阅读次数:
276