希尔排序是由D.L.Shell于1959年提出的,所以称为希尔排序。希尔排序又称缩小增量排序,是插入排序的一种改进。
基本思想:希尔排序是基于插入排序的以下特点:待排序的序列元素数量越少排序速度越快;待排序序列的元素基本有序时排序速度越快;基于以上思想将待排序序列分为多个子序列分别进行插入排序,然后...
分类:
其他好文 时间:
2014-05-13 22:11:01
阅读次数:
272
前几天写了个音乐播放器,添加了歌词播放功能,起初一直在考虑是否要用c语言的排序方法。没想到
oc 强大到早已做好了方法。简单又高大上。 [arrayNamesortUsingSelector:@selector(compare:)];
arrayName 是可变数组,compare: 是...
分类:
移动开发 时间:
2014-05-13 22:00:41
阅读次数:
422
1. if elif else 2. 条件表达式:三元操作符: smaller = x if x
< y else y == if x < y : smaller =x else : smaller = y3. range(start, end,
step=1) 4. xrange(): 当有一个很...
分类:
编程语言 时间:
2014-05-13 21:48:28
阅读次数:
362
前面我们写了常见的几种排序算法,并分析了各种算法的实现思想,及时间复杂度等情况,但由于只是分析,木有实际的数据做对比测试,所以对各个算法的效率也没有一个明确的概念,下面我们就通过具体的测试来看看同算法之间的效率差距。声明11个长度为100的元素取值范围为0到1000的序列int
length = 1...
分类:
其他好文 时间:
2014-05-13 21:46:24
阅读次数:
323
桶排序是一种效率很高的排序算法,它的时间复杂度为O(n),但桶排序有一定的限制,只有当待排序序列的元素为0到某一确定取值范围的整数时才适用,典型的例子比如成绩的排序等。
算法思想: 设待排序序列的元素取值范围为0到m,则我们新建一个大小为m+1的临时数组并把初始值都设为0,遍历待排序序列,把待排序序...
分类:
其他好文 时间:
2014-05-13 21:23:40
阅读次数:
351
#!/usr/bin/envpython#coding:utf8fromoptparseimportOptionParserimportsys,os#parser=OptionParser()defset():parser=OptionParser("Usage:%prog[file1][file2]...")parser.add_option("-c","--chars",dest="characters",action="store_true",default=False,help="onlycountc..
分类:
编程语言 时间:
2014-05-13 04:31:41
阅读次数:
488
#!/usr/bin/envpython#coding:utf8#此脚本为查找递归目录下所有文件匹配的内容importos,sys,tabdefpaths(path):list_path=os.walk(path)all_file=[]forp,d,flinlist_path:forfinfl:pfile=os.path.join(p,f)ifos.path.isdir(pfile):paths(pfile)all_file.append(pfile)returnall..
分类:
编程语言 时间:
2014-05-13 03:49:34
阅读次数:
426
#!/usr/bin/envpython#coding:utf8importsmtplib,sysfromemail.mime.textimportMIMETextfromconfig.mailssimportmail_list,contentdefsend_mail():mail_host,mail_user,mail_pass,mail_postfix,sub,me,mailto_list=mail_listme=mail_user+"<"+mail_user+"@"+mail_postfix+"&..
分类:
编程语言 时间:
2014-05-13 02:40:50
阅读次数:
503
#!/usr/bin/envpython#coding:utf8importos,sysimportdatetime,shutil,subprocessfromconfig.configimportslow_configclasscut_mysql(object):mysql_user,mysql_pass,date_day,slow_log_name,slow_log_path,mysqlsla_log_name,mysqldumpslow_log_name,new_log_path,new_log_nam..
分类:
数据库 时间:
2014-05-13 02:39:47
阅读次数:
482
#!/usr/bin/envpython#coding:utf8importos,sysimportmd5,tabfrommysql_co.my_dbimportset_mysqlfromssh_co.ssh_connectimportsshdfromssh_co.cfg.configimportssh_message,item_pathfromfileimportfindfiledefmy_mysql():db_file={}my_connect=set_mysql()f_file=findfile.mai..
分类:
编程语言 时间:
2014-05-13 01:44:22
阅读次数:
449